Method, Apparatus, and System for Executing Distributed Transaction Resources

ABSTRACT

The method includes: receiving, by a first managed object device, a first transaction resource creation request that is sent by an application server and includes an identifier of a first to-be-operated resource, a first execution time, and a first to-be-executed operation; receiving, by a second managed object device, a second transaction resource creation request that is sent by the application server and includes an identifier of a second to-be-operated resource, a second execution time, and a second to-be-executed operation; successfully creating, by the first managed object device, a first transaction resource according to the first transaction resource creation request, and successfully creating, by the second managed device, a second transaction resource according to the second transaction resource creation request.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2015/080607, filed on Jun. 2, 2015, which claims priority toChinese Patent Application No. 201410637221.X, filed on Nov. 12, 2014.The disclosures of the aforementioned applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

Embodiments of the present invention relate to computer technologies,and in particular, to a method, an apparatus, and a system for executingdistributed transaction resources.

BACKGROUND

Currently, a machine to machine (M2M for short hereinafter)communications, namely, an Internet of Things technology, is extensivelyapplied in more industries and fields, such as intelligent traffic,agricultural irrigation, and smart home industries. To meet applicationservice requirements in different industries, an M2M system operatordevelops a unified M2M platform to implement some common capabilities,for example, data access and storage, data sharing and transmission, andgroup communication. The M2M platform may be accessed by different typesof managed object devices (for example, sensors), and may provide anorthbound application access interface, allowing application servers ofdifferent industries to invoke, by using the access interface, thecommon capabilities provided by the M2M platform.

For distributed transactions in an M2M system using a RESTfularchitecture, a transaction means that a task or operation needs to becompleted by using multiple requests between an application server andmanaged object devices. The transaction is required to have atomicity(herein the atomicity means that the transaction is an indivisible workunit, and all operations included in the transaction should be executedto ensure execution integrity). In addition, in some scenarios of theM2M system in which a distributed transaction is committed, transactionresources on multiple servers require simultaneous execution. Forexample, in a scenario of intelligent irrigation including a watersource and a large quantity of valves (these valves are managed objectdevices), which piece of farmland is irrigated and how much water issupplied are determined by opening/closing of a valve and an openingpercentage. Specifically, a piece of land is divided into multipleplots; soil sensors that are deployed on the land and distributed indifferent plots collect degrees of water shortage in soil, and reportcollected data of water shortage of the soil to an M2M platform by usinggateways deployed in different plots. By reading the data of the sensorson the M2M platform, an application server determines whether soil ineach plot is currently short of water, and implements land irrigation bycontrolling opening/closing of a valve. Therefore, irrigation on onepiece of land needs to be implemented by adjusting multiple valves, forexample, opening a canal head valve, a submain pipe valve, a branchcanal valve, and a branch pipe valve. These valves need to be openedsimultaneously. Otherwise, if the canal head valve and the submain pipevalve are opened, but the branch canal valve is not opened, a branchcanal is caused to overflow. Alternatively, at some thin pipes, anasynchronous adjustment of valves may cause abnormal pressure in thethin pipes, and cause joints to loosen or cause the pipes to deform, andso on.

The prior art provides a method for executing distributed transactionresources in the RESTful architecture, that is, a try-confirm/cancel(TCC for short hereafter) method. Specifically, an application serversends an update request to multiple managed object devices. Each updaterequest carries an expiry time of the update request. A managed objectdevice determines whether the managed object device meets a conditionfor executing the update request. If yes, the managed object devicereturns a success response to the application server, and waits for acommit request that is sent by the application server for the updaterequest. If not, the managed object device returns a failure response tothe application server, and the application server enters a rollbackphase. After the application server receives a success response returnedby each managed object device, the application server sends a commitrequest to each of the multiple managed object devices, so that themultiple managed object devices execute the update request, that is,complete execution of transaction resources, and enter a final state. Ifa managed object device fails to receive, before the expiry timearrives, the commit request sent by the application server, the updaterequest previously received is automatically canceled, so that themanaged object device returns to an initial state.

However, in the method provided by the prior art, because there is adelay in receiving the commit request by each managed object device, themultiple managed object devices cannot simultaneously execute thetransaction resources (that is, cannot simultaneously execute the updaterequest). Consequently, reliability of the distributed system isaffected. In addition, in the prior art, at least two requests (theforegoing update request and commit request) are required between atransaction coordinator and a server before a transaction can becompleted, and signaling overheads of the transaction are relativelyhigh.

SUMMARY

Embodiments of the present invention provide a method, an apparatus, anda system for executing distributed transaction resources, so as toresolve a technical problem in the prior art that reliability of adistributed system is affected because multiple managed object devicescannot execute a transaction resource update request simultaneously dueto a delay in receiving a commit request, and resolve a technicalproblem in the prior art that signaling overheads are high.

According to a first aspect, an embodiment of the present inventionprovides a method for executing distributed transaction resources for amachine to machine communications (M2M) system. The method includesreceiving, by a first managed object device of the M2M system, a firsttransaction resource creation request sent by an application server ofthe M2M system for a first transaction. The first transaction resourcecreation request includes an identifier of a first to-be-operatedresource, a first execution time, and a first to-be-executed operation.A second transaction resource creation request sent by the applicationserver for the first transaction is received by a second managed objectdevice of the M2M system different from the first managed object device.The second transaction resource creation request includes an identifierof a second to-be-operated resource, a second execution time, and asecond to-be-executed operation, and the first execution time and thesecond execution time are the same. The method further includessuccessfully creating, by the first managed object device, a firsttransaction resource of the first transaction according to the firsttransaction resource creation request, and successfully creating, by thesecond managed object device, a second transaction resource of the firsttransaction according to the second transaction resource creationrequest. The first transaction resource includes the first executiontime and the first to-be-executed operation. The second transactionresource includes the second execution time and the secondto-be-executed operation. The method further includes sending, by thefirst managed object device, a response indicative of successfulcreation of the first transaction resource of the first transaction tothe application server, and sending, by the second managed objectdevice, a response indicative of successful creation of the secondtransaction resource of the first transaction to the application server.When the first execution time arrives, respectively executing, by thefirst managed object device and the second managed device, theoperations to be executed by the devices.

With reference to the first aspect, in a first possible implementationmanner of the first aspect, the method further includes receiving, bythe first managed object device, a third transaction resource creationrequest sent by the application server for a second transaction, wherethe third transaction resource creation request includes the identifierof the first to-be-operated resource, a third execution time, and athird to-be-executed operation. A fourth transaction resource creationrequest sent by the application server for the second transaction isreceived by the second managed object device. The fourth transactionresource creation request includes the identifier of the secondto-be-operated resource, a fourth execution time, and a fourthto-be-executed operation, and the third execution time and the fourthexecution time are the same. Upon determining that a third transactionresource of the second transaction fails to be created according to thethird transaction resource creation request, sending a responseindicative of unsuccessful creation of the third transaction resource ofthe second transaction to the application server; and successfullycreating, by the second managed device, a fourth transaction resource ofthe second transaction according to the fourth transaction resourcecreation request, and sending a response indicative of successfulcreation of the fourth transaction resource of the second transaction tothe application server, where the response indicative of successfulcreation of the fourth transaction resource carries an identifier of thefourth transaction resource. The method further includes receiving, bythe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource to theapplication server, a processing request sent by the application serverfor the fourth transaction resource of the second transaction, where theprocessing request for the fourth transaction resource of the secondtransaction carries the identifier of the fourth transaction resource.The method further includes processing, by the second managed objectdevice that sends the response indicative of successful creation of thefourth transaction resource to the application server, the createdfourth transaction resource according to the identifier of the fourthtransaction resource.

With reference to the first possible implementation manner of the firstaspect, in a second possible implementation manner of the first aspect,the determining, by the first managed object device, that a thirdtransaction resource of the second transaction fails to be createdaccording to the third transaction resource creation request includesdetermining, by the first managed object device, that a firsttransaction resource queue exists on the first managed object device,where the first transaction resource queue includes at least onetransaction resource. The method further includes determining, by thefirst managed object device according to the third execution time and astate of the first to-be-operated resource of the first managed objectdevice, that the third transaction resource does not meet a presetresource creation condition. The method further includes determining, bythe first managed object device according to the preset resourcecreation condition, to update the third execution time to a time laterthan an execution time of a transaction resource in the firsttransaction resource queue; and sending, by the first managed objectdevice, a second failure response carrying the updated third executiontime to the application server.

With reference to the first possible implementation manner of the firstaspect or the second possible implementation manner of the first aspect,in a third possible implementation manner of the first aspect, thesuccessfully creating, by the second managed object device, a fourthtransaction resource of the second transaction according to the fourthtransaction resource creation request includes determining, by thesecond managed object device, that a second transaction resource queueexists on the second managed object device, where the second transactionresource queue includes at least one transaction resource. The methodfurther includes determining, by the second managed object deviceaccording to the fourth execution time and a state of the secondto-be-operated resource of the second managed object device, that thefourth transaction resource meets the preset resource creationcondition, and creating the fourth transaction resource.

With reference to any one of the first possible implementation manner ofthe first aspect to the third possible implementation manner of thefirst aspect, in a fourth possible implementation manner of the firstaspect, the processing request for the fourth transaction resource ofthe second transaction is an update request that carries the identifierof the fourth transaction resource and the updated third execution time;and the processing, by the second managed object device that sends theresponse indicative of successful creation of the fourth transactionresource to the application server, the created fourth transactionresource according to the identifier of the fourth transaction resourcespecifically include successfully updating, by the second managed objectdevice, the fourth transaction resource according to the updated thirdexecution time, and after the update succeeds, returning an updatesuccess response message to the application server; or in case failingto update the fourth transaction resource according to the updated thirdexecution time, and returning an update failure response message to theapplication server.

With reference to the fourth possible implementation manner of the firstaspect, in a fifth possible implementation manner of the first aspect,the successfully updating, by the second managed object device, thefourth transaction resource according to the updated third executiontime includes deleting, by the second managed object device, the fourthtransaction resource on the second managed object device according tothe identifier of the fourth transaction resource; using, by the secondmanaged object device, the updated third execution time as an executiontime of a new fourth transaction resource; determining, by the secondmanaged object device according to the execution time of the new fourthtransaction resource and the state of the second to-be-operated resourceof the second managed object device, that the new fourth transactionresource meets the preset resource creation condition; and creating, bythe second managed object device, the new fourth transaction resourceaccording to the updated third execution time.

With reference to any one of the first possible implementation manner ofthe first aspect to the third possible implementation manner of thefirst aspect, in a sixth possible implementation manner of the firstaspect, the processing request for the fourth transaction resource ofthe second transaction is a deletion request that carries the identifierof the fourth transaction resource; and the processing, by the secondmanaged object device that sends the response indicative of successfulcreation of the fourth transaction resource to the application server,the created fourth transaction resource according to the identifier ofthe fourth transaction resource specifically includes: deleting, by thesecond managed object device, the fourth transaction resource on thesecond managed object device according to the identifier of the fourthtransaction resource.

With reference to the sixth possible implementation manner of the firstaspect, in a seventh possible implementation manner of the first aspect,one transaction resource in the second transaction resource queue is ina reserved state, and after the deleting, by the second managed objectdevice, the fourth transaction resource on the second managed objectdevice according to the identifier of the fourth transaction resource,the method further includes determining, by the second managed objectdevice, according to the state of the second to-be-operated resourceafter a transaction resource at a first position in the secondtransaction resource queue is executed, whether a transaction resourceat the second position can be executed successfully, where the firstposition is a position previous to the fourth transaction resource inthe second transaction resource queue, and the second position is aposition next to the fourth transaction resource in the secondtransaction resource queue. If the transaction resource at the secondposition is executed successfully, sending, by the second managed objectdevice, a first deletion response to the application server, and afterthe transaction resource at the first position is executed, updating astate of the transaction resource at the second position to the reservedstate. Alternatively, if the transaction resource at the second positionfails to be executed, deleting, by the second managed object device, thetransaction resource at the second position.

With reference to the sixth possible implementation manner of the firstaspect, in an eighth possible implementation manner of the first aspect,at least two transaction resources in the second transaction resourcequeue are in a reserved state, and after the deleting, by the secondmanaged object device, the fourth transaction resource on the secondmanaged object device according to the identifier of the fourthtransaction resource, the method further includes: determining, by thesecond managed object device, whether a transaction resource in asemi-reserved state in the second transaction resource queue meets apreset deletion condition; and if yes, deleting, by the second managedobject device, the transaction resource in the semi-reserved state, andsending a second deletion response to the application server; or if not,determining, by the second managed object device, according to the stateof the second to-be-operated resource after any transaction resourceprevious to the transaction resource in the semi-reserved state isexecuted, that the transaction resource in the semi-reserved state canbe executed successfully, and updating, by the second managed objectdevice, the transaction resource in the semi-reserved state to thereserved state.

According to a second aspect, an embodiment of the present inventiondescribes a method for executing distributed transaction resources for amachine to machine communications (M2M) system. The method includessending, by an application server of the M2M system, a first transactionresource creation request for a first transaction to a first managedobject device of the M2M system. The first transaction resource creationrequest includes an identifier of a first to-be-operated resource, afirst execution time, and a first to-be-executed operation. The methodfurther includes sending, by the application server, a secondtransaction resource creation request for the first transaction to asecond managed object device of the M2M system. The second transactionresource creation request includes an identifier of a secondto-be-operated resource, a second execution time, and a secondto-be-executed operation, and the first execution time and the secondexecution time are the same. The method further includes receiving, bythe application server, within a preset time, a response that is sent bythe second managed object device and that is indicative of successfulcreation of a second transaction resource of the first transaction, andreceiving, within the preset time, a response that is sent by the firstmanaged object device and that is indicative of successful creation of afirst transaction resource of the first transaction.

With reference to the second aspect, in a first possible implementationmanner of the second aspect, the method further includes sending, by theapplication server, a third transaction resource creation request for asecond transaction to the first managed object device, where the thirdtransaction resource creation request includes the identifier of thefirst to-be-operated resource, a third execution time, and a thirdto-be-executed operation; sending, by the application server, a fourthtransaction resource creation request for the second transaction to thesecond managed object device, where the fourth transaction resourcecreation request includes the identifier of the second to-be-operatedresource, a fourth execution time, and a fourth to-be-executedoperation, and the third execution time and the fourth execution timeare the same; receiving, by the application server, within a presettime, a response that is sent by the first managed object device andthat is indicative of unsuccessful creation of a third transactionresource of the second transaction, and receiving, within the presettime, a response that is sent by the second managed object device andthat is indicative of successful creation of a fourth transactionresource of the second transaction, where the response indicative ofsuccessful creation of the fourth transaction resource carries anidentifier of the fourth transaction resource; and sending, by theapplication server, based on the response indicative of unsuccessfulcreation of the third transaction resource of the second transaction andthe response indicative of successful creation of the fourth transactionresource of the second transaction, a processing request for the fourthtransaction resource of the second transaction to the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource, where the processing request for thefourth transaction resource of the second transaction carries theidentifier of the fourth transaction resource.

With reference to the first possible implementation manner of the secondaspect, in a second possible implementation manner of the second aspect,the sending, by the application server, based on the response indicativeof unsuccessful creation of the third transaction resource of the secondtransaction and the response indicative of successful creation of thefourth transaction resource of the second transaction, a processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource includes:determining, by the application server, that the response indicative ofunsuccessful creation of the third transaction resource of the secondtransaction is a first failure response that does not carry an updatedthird execution time, and sending a deletion request carrying theidentifier of the fourth transaction resource to the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource; or determining, by the applicationserver, that the response indicative of unsuccessful creation of thethird transaction resource of the second transaction is a second failureresponse carrying the updated third execution time, and sending anupdate request carrying the updated third execution time and theidentifier of the fourth transaction resource to the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource; and the method further includes:sending, by the application server, a third transaction resourcecreation request carrying the updated third execution time to the firstmanaged device.

According to a third aspect, an embodiment of the present inventionprovides an application server, applied to a machine to machinecommunications M2M system, where the M2M system includes at least twomanaged object devices and the application server, a first managedobject device is any one of the at least two managed object devices, andthe second managed object is any managed object device in the at leasttwo managed object devices except the first managed object device; andthe application server includes: a sending module, configured to send afirst transaction resource creation request for a first transaction tothe first managed object device, where the first transaction resourcecreation request includes an identifier of a first to-be-operatedresource, a first execution time, and a first to-be-executed operation;and further configured to send a second transaction resource creationrequest for the first transaction to the second managed object device,where the second transaction resource creation request includes theidentifier of the first to-be-operated resource, a second executiontime, and a second to-be-executed operation, and the first executiontime and the second execution time are the same; and a receiving module,configured to receive, within a preset time, a response that is sent bythe second managed object device and that is indicative of successfulcreation of a second transaction resource of the first transaction, andreceive a response that is sent by the first managed object device andthat is indicative of successful creation of a first transactionresource of the first transaction.

With reference to the third aspect, in a first possible implementationmanner of the third aspect, the sending module is further configured tosend a third transaction resource creation request for a secondtransaction to the first managed object device, where the thirdtransaction resource creation request includes the identifier of thefirst to-be-operated resource, a third execution time, and a thirdto-be-executed operation; and further configured to send a fourthtransaction resource creation request for the second transaction to thesecond managed object device, where the fourth transaction resourcecreation request includes the identifier of the second to-be-operatedresource, a fourth execution time, and a fourth to-be-executedoperation, and the third execution time and the fourth execution timeare the same. The receiving module is further configured to receive,within a preset time, a response that is sent by the first managedobject device and that is indicative of creation failure of a thirdtransaction resource of the second transaction, and receive, within thepreset time, a response that is sent by the second managed object deviceand that is indicative of successful creation of a fourth transactionresource of the second transaction. The response indicative ofsuccessful creation of the fourth transaction resource carries anidentifier of the fourth transaction resource. The sending module isfurther configured to send, based on the response indicative ofunsuccessful creation of the third transaction resource of the secondtransaction and the response indicative of successful creation of thefourth transaction resource of the second transaction, a processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource, where theprocessing request for the fourth transaction resource of the secondtransaction carries the identifier of the fourth transaction resource.

With reference to the first possible implementation manner of the thirdaspect, in a second possible implementation manner of the third aspect,the sending module is specifically configured to determine that theresponse indicative of unsuccessful creation of the third transactionresource of the second transaction is a first failure response that doesnot carry an updated third execution time, and send a deletion requestcarrying the identifier of the fourth transaction resource to the secondmanaged object device that sends the response indicative of successfulcreation of the fourth transaction resource; or determine that theresponse indicative of unsuccessful creation of the third transactionresource of the second transaction is a second failure response carryingthe updated third execution time, and send an update request carryingthe updated third execution time and the identifier of the fourthtransaction resource to the second managed object device that sends theresponse indicative of successful creation of the fourth transactionresource. The sending module is further configured to send a thirdtransaction resource creation request carrying the updated thirdexecution time to the first managed device.

According to a fourth aspect, an embodiment of the present inventionprovides a system for executing distributed transaction resources,applied to a machine to machine communications M2M system, where the M2Msystem includes at least two managed object devices and an applicationserver, a first managed object device is any one of the at least twomanaged object devices, and a second managed object device is anymanaged object device in the at least two managed object devices exceptthe first managed object device; and the system for executingdistributed transaction resources includes the first managed objectdevice and the second managed object device. The first managed objectdevice is configured to receive a first transaction resource creationrequest sent by the application server for a first transaction,successfully create a first transaction resource of the firsttransaction according to the first transaction resource creationrequest, and send a response indicative of successful creation of thefirst transaction resource of the first transaction to the applicationserver, where the first transaction resource creation request includesan identifier of a first to-be-operated resource, a first executiontime, and a first to-be-executed operation. The second managed objectdevice is configured to receive a second transaction resource creationrequest sent by the application server for the first transaction,successfully create a second transaction resource of the firsttransaction according to the second transaction resource creationrequest, and send a response indicative of successful creation of thesecond transaction resource of the first transaction to the applicationserver. The second transaction resource creation request includes anidentifier of a second to-be-operated resource, a second execution time,and a second to-be-executed operation, the first execution time and thesecond execution time are the same, the first transaction resourceincludes the first execution time and the first to-be-executedoperation, and the second transaction resource includes the secondexecution time and the second to-be-executed operation. When the firstexecution time arrives, the first managed object device and the secondmanaged device are configured to respectively execute the operations tobe executed by the devices.

With reference to the fourth aspect, in a first possible implementationmanner of the fourth aspect, the first managed object device is furtherconfigured to receive a third transaction resource creation request sentby the application server for a second transaction, determine that athird transaction resource of the second transaction fails to be createdaccording to the third transaction resource creation request, and send aresponse indicative of unsuccessful creation of the third transactionresource of the second transaction to the application server, where thethird transaction resource creation request includes the identifier ofthe first to-be-operated resource, a third execution time, and a thirdto-be-executed operation. The second managed object device is furtherconfigured to receive a fourth transaction resource creation requestsent by the application server for the second transaction, successfullycreate a fourth transaction resource of the second transaction accordingto the fourth transaction resource creation request, and send a responseindicative of successful creation of the fourth transaction resource ofthe second transaction to the application server, where the fourthtransaction resource creation request includes the identifier of thesecond to-be-operated resource, a fourth execution time, and a fourthto-be-executed operation, the third execution time and the fourthexecution time are the same, and the response indicative of successfulcreation of the fourth transaction resource carries an identifier of thefourth transaction resource. The second managed object device that sendsthe response indicative of successful creation of the fourth transactionresource to the application server is further configured to receive aprocessing request sent by the application server for the fourthtransaction resource of the second transaction, and process the createdfourth transaction resource according to the identifier of the fourthtransaction resource. The processing request for the fourth transactionresource of the second transaction carries the identifier of the fourthtransaction resource.

With reference to the first possible implementation manner of the fourthaspect, in a second possible implementation manner of the fourth aspect,the first managed object device is specifically configured to determinethat a first transaction resource queue exists on the first managedobject device, determine, according to the third execution time and astate of the first to-be-operated resource of the first managed objectdevice, that the third transaction resource does not meet a presetresource creation condition, determine, according to the preset resourcecreation condition, to update the third execution time to a time laterthan an execution time of a transaction resource in the firsttransaction resource queue, and send a second failure response carryingthe updated third execution time to the application server. The firsttransaction resource queue includes at least one transaction resource.

With reference to the first possible implementation manner of the fourthaspect or the second possible implementation manner of the fourthaspect, in a third possible implementation manner of the fourth aspect,the second managed object device is specifically configured to determinethat a second transaction resource queue exists on the second managedobject device, determine, according to the fourth execution time and astate of the second to-be-operated resource of the second managed objectdevice, that the fourth transaction resource meets the preset resourcecreation condition, and create the fourth transaction resource, wherethe second transaction resource queue includes at least one transactionresource.

With reference to any one of the first possible implementation manner ofthe fourth aspect to the third possible implementation manner of thefourth aspect, in a fourth possible implementation manner of the fourthaspect, the processing request for the fourth transaction resource ofthe second transaction is an update request that carries the identifierof the fourth transaction resource and the updated third execution time;and the second managed object device is further configured tosuccessfully update the fourth transaction resource according to theupdated third execution time, and after the update succeeds, return anupdate success response message to the application server; or fail toupdate the fourth transaction resource according to the updated thirdexecution time, and return an update failure response message to theapplication server.

With reference to the fourth possible implementation manner of thefourth aspect, in a fifth possible implementation manner of the fourthaspect, the second managed object device is further configured to deletethe fourth transaction resource on the second managed object deviceaccording to the identifier of the fourth transaction resource, use theupdated third execution time as an execution time of a new fourthtransaction resource, determine, according to the execution time of thenew fourth transaction resource and the state of the secondto-be-operated resource of the second managed object device, that thenew fourth transaction resource meets the preset resource creationcondition, and create the new fourth transaction resource according tothe updated third execution time.

With reference to any one of the first possible implementation manner ofthe fourth aspect to the third possible implementation manner of thefourth aspect, in a sixth possible implementation manner of the fourthaspect, the processing request for the fourth transaction resource ofthe second transaction is a deletion request that carries the identifierof the fourth transaction resource, and the second managed object deviceis further configured to delete the fourth transaction resource on thesecond managed object device according to the identifier of the fourthtransaction resource.

With reference to the sixth possible implementation manner of the fourthaspect, in a seventh possible implementation manner of the fourthaspect, one transaction resource in the second transaction resourcequeue is in a reserved state, and the second managed object device isfurther configured to determine, according to the state of the secondto-be-operated resource after a transaction resource at a first positionin the second transaction resource queue is executed, whether atransaction resource at the second position can be executedsuccessfully, where the first position is a position previous to thefourth transaction resource in the second transaction resource queue,and the second position is a position next to the fourth transactionresource in the second transaction resource queue. If the transactionresource at the second position is executed successfully, the secondmanaged object device is further configured to send a first deletionresponse to the application server, and after the transaction resourceat the first position is executed, update a state of the transactionresource at the second position to the reserved state; or if thetransaction resource at the second position fails to be executed, thesecond managed object device is further configured to delete thetransaction resource at the second position.

With reference to the sixth possible implementation manner of the fourthaspect, in an eighth possible implementation manner of the fourthaspect, at least two transaction resources in the second transactionresource queue are in a reserved state, and the second managed objectdevice is further configured to determine whether a transaction resourcein a semi-reserved state in the second transaction resource queue meetsa preset deletion condition. If the transaction resource in thesemi-reserved state in the second transaction resource queue meets thepreset deletion condition, the second managed object device is furtherconfigured to delete the transaction resource in the semi-reservedstate, and send a second deletion response to the application server; orif the transaction resource in the semi-reserved state in the secondtransaction resource queue does not meet the preset deletion condition,the second managed object device is further configured to determine,according to the state of the second to-be-operated resource after anytransaction resource previous to the transaction resource in thesemi-reserved state is executed, that the transaction resource in thesemi-reserved state can be executed successfully, and update thetransaction resource in the semi-reserved state to the reserved state.

According to a fifth aspect, an embodiment of the present inventionprovides a managed object device, applied to a machine to machinecommunications M2M system, where the M2M system includes at least twomanaged object devices and an application server, the managed objectdevice is any one of the at least two managed object devices, and asecond managed object device is any managed object device in the atleast two managed object devices except the managed object device; andthe managed object device includes: a receiving module, configured toreceive a first transaction resource creation request sent by theapplication server for a first transaction. The first transactionresource creation request includes an identifier of a firstto-be-operated resource, a first execution time, and a firstto-be-executed operation, the first execution time is the same as asecond execution time in a second transaction resource creation requestfor the first transaction, and the second transaction resource creationrequest is received by the second managed object device other than themanaged object device in the M2M system. A creation module is configuredto successfully create a first transaction resource according to thefirst transaction resource creation request, where the first transactionresource includes the first execution time and the first to-be-executedoperation. A determining module is configured to determine, when thefirst execution time arrives, that a processing request sent by theapplication server for the first transaction resource of the firsttransaction is not received, where the processing request for the firsttransaction resource of the first transaction is sent after theapplication server receives a response that is sent by the secondmanaged object device and that is indicative of unsuccessful creation ofa second transaction resource of the first transaction. A processingmodule is configured to execute the first to-be-executed operation.

With reference to the fifth aspect, in a first possible implementationmanner of the fifth aspect, the managed object device further includes asending module. The receiving module is further configured to receive athird transaction resource creation request sent by the applicationserver for a second transaction, where the third transaction resourcecreation request includes the identifier of the first to-be-operatedresource, a third execution time, and a third to-be-executed operation,and the third execution time is the same as a fourth execution time in afourth transaction resource creation request received by the secondmanaged object device for the second transaction. The creation module isfurther configured to determine that a third transaction resource failsto be created according to the third transaction resource creationrequest. The sending module is configured to send a response indicativeof unsuccessful creation of the third transaction resource of the secondtransaction to the application server.

With reference to the first possible implementation manner of the fifthaspect, in a second possible implementation manner of the fifth aspect,the creation module is specifically configured to determine that a firsttransaction resource queue exists on the managed object device,determine, according to the third execution time and a state of thefirst to-be-operated resource of the managed object device, that thethird transaction resource does not meet a preset resource creationcondition, and determine, according to the preset resource creationcondition, to update the third execution time to a time later than anexecution time of a transaction resource in the first transactionresource queue, where the first transaction resource queue includes atleast one transaction resource. The sending module is specificallyconfigured to send a second failure response carrying the updated thirdexecution time to the application server.

With reference to the first possible implementation manner of the fifthaspect, in a third possible implementation manner of the fifth aspect,the managed object device further includes a sending module. Thereceiving module is further configured to receive a third transactionresource creation request sent by the application server for a secondtransaction, where the third transaction resource creation requestincludes the identifier of the first to-be-operated resource, a thirdexecution time, and a third to-be-executed operation, and the thirdexecution time is the same as a fourth execution time in a fourthtransaction resource creation request received by the second managedobject device for the second transaction. The creation module is furtherconfigured to successfully create the third transaction resourceaccording to the third transaction resource creation request. Thesending module is configured to send a response indicative of successfulcreation of the third transaction resource of the second transaction tothe application server, where the response indicative of successfulcreation of the third transaction resource carries an identifier of thethird transaction resource. The determining module is further configuredto determine, before the third execution time arrives, that a processingrequest sent by the application server for the third transactionresource of the second transaction is received, where the processingrequest for the third transaction resource of the second transactioncarries the identifier of the third transaction resource. The processingmodule is further configured to process the created third transactionresource according to the identifier of the third transaction resource.

With reference to the third possible implementation manner of the fifthaspect, in a fourth possible implementation manner of the fifth aspect,the creation module is specifically configured to determine that a firsttransaction resource queue exists on the managed object device,determine, according to the third execution time and a state of thefirst to-be-operated resource of the managed object device, that thethird transaction resource meets a preset resource creation condition,and create the third transaction resource, where the first transactionresource queue includes at least one transaction resource.

With reference to the third possible implementation manner of the fifthaspect or the fourth possible implementation manner of the fifth aspect,in a fifth possible implementation manner of the fifth aspect, theprocessing request for the third transaction resource of the secondtransaction is an update request that carries the identifier of thethird transaction resource and an updated fourth execution time, and theprocessing module is specifically configured to successfully update thethird transaction resource according to the updated fourth executiontime, and after the update succeeds, return an update success responsemessage to the application server; or fail to update the thirdtransaction resource according to the updated fourth execution time, andreturn an update failure response message to the application server.

With reference to the fifth possible implementation manner of the fifthaspect, in a sixth possible implementation manner of the fifth aspect,the processing module is specifically configured to delete the thirdtransaction resource on the managed object device according to theidentifier of the third transaction resource, use the updated fourthexecution time as an execution time of a new third transaction resource,determine, according to the execution time of the new third transactionresource and the state of the first to-be-operated resource of themanaged object device, that the new third transaction resource meets thepreset resource creation condition, and create the new third transactionresource according to the updated fourth execution time.

With reference to the third possible implementation manner of the fifthaspect or the fourth possible implementation manner of the fifth aspect,in a seventh possible implementation manner of the fifth aspect, theprocessing request for the third transaction resource of the secondtransaction is a deletion request that carries the identifier of thethird transaction resource, and the processing module is specificallyconfigured to delete the third transaction resource on the managedobject device according to the identifier of the third transactionresource.

With reference to the seventh possible implementation manner of thefifth aspect, in an eighth possible implementation manner of the fifthaspect, one transaction resource in the first transaction resource queueis in a reserved state, and the processing module is further configuredto: determine, according to the state of the first to-be-operatedresource after a transaction resource at a first position in the firsttransaction resource queue is executed, whether a transaction resourceat the second position can be executed successfully; and if thetransaction resource at the second position is executed successfully,send a first deletion response to the application server, and after thetransaction resource at the first position is executed, update a stateof the transaction resource at the second position to the reservedstate; or if the transaction resource at the second position fails to beexecuted, delete the transaction resource at the second position; wherethe first position is a position previous to the third transactionresource in the first transaction resource queue, and the secondposition is a position next to the third transaction resource in thefirst transaction resource queue.

With reference to the seventh possible implementation manner of thefifth aspect, in a ninth possible implementation manner of the fifthaspect, at least two transaction resources in the first transactionresource queue are in a reserved state, and the processing module isfurther configured to: determine whether a transaction resource in asemi-reserved state in the first transaction resource queue meets apreset deletion condition; and if yes, delete the transaction resourcein the semi-reserved state, and send a second deletion response to theapplication server; or if not, determine, according to the state of thefirst to-be-operated resource after any transaction resource previous tothe transaction resource in the semi-reserved state is executed, thatthe transaction resource in the semi-reserved state can be executedsuccessfully, and update the transaction resource in the semi-reservedstate to the reserved state.

In the method, apparatus, and system for executing distributedtransaction resources according to the embodiments of the presentinvention, transaction resource creation requests sent to multiplemanaged object devices carry a same execution time, so that whentransaction resources are created successfully and the execution timearrives, the multiple managed object devices simultaneously execute thetransaction resources created by the managed object devices, therebyensuring that the transaction resources are executed simultaneously. Inaddition, in the embodiments of the present invention, to ensure thatthe transaction resources are executed simultaneously, an applicationserver needs to send only one transaction resource creation request to amanaged object device. Therefore, signaling overheads of the applicationserver are reduced.

BRIEF DESCRIPTION OF THE DRAWINGS

To describe the technical solutions in the embodiments of the presentinvention more clearly, the following briefly describes the accompanyingdrawings required for describing the embodiments or the prior art.Apparently, the accompanying drawings in the following description showsome embodiments of the present invention, and a person of ordinaryskill in the art may still derive other drawings from these accompanyingdrawings without creative efforts.

FIG. 1 is a schematic flowchart of Embodiment 1 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 2 is a schematic diagram of an M2M network architecture forintelligent irrigation according to the present invention;

FIG. 3 is a schematic flowchart of Embodiment 2 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 4 is another schematic flowchart of Embodiment 2 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 5 is another schematic flowchart of Embodiment 2 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 6 is another schematic flowchart of Embodiment 2 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 7 is a schematic flowchart of Embodiment 3 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 8 is a schematic flowchart of Embodiment 4 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 9 is a schematic flowchart of Embodiment 5 of a method forexecuting distributed transaction resources according to the presentinvention;

FIG. 10 is a schematic structural diagram of an embodiment of anapplication server according to the present invention;

FIG. 11 is a schematic structural diagram of Embodiment 1 of a managedobject device according to the present invention;

FIG. 12 is a schematic structural diagram of Embodiment 2 of a managedobject device according to the present invention; and

FIG. 13 is a schematic structural diagram of an embodiment of a systemfor executing distributed transaction resources according to the presentinvention.

DETAILED DESCRIPTION OF ILLUSTRATIVE EMBODIMENTS

To make the objectives, technical solutions, and advantages of theembodiments of the present invention clearer, the following clearlydescribes the technical solutions in the embodiments of the presentinvention with reference to the accompanying drawings in the embodimentsof the present invention. Apparently, the described embodiments are somebut not all of the embodiments of the present invention. All otherembodiments obtained by a person of ordinary skill in the art based onthe embodiments of the present invention without creative efforts shallfall within the protection scope of the present invention.

The technical solution in this application may be applied to a machineto machine (M2M for short hereinafter) communications system. The systemmay include at least two managed object devices and an applicationserver. A first managed object device involved in this application maybe any one of the at least two managed object devices, and a secondmanaged object may be any managed object device in the at least twomanaged object devices except the first managed object device. If amanaged object device in the M2M system is defined as the first managedobject device, herein the second managed object device is any managedobject device in the M2M system except the first managed object device.It should be noted that, the managed object device in this applicationmay be a server, a communication gateway, or an M2M platform. Theapplication server may be a transaction coordinator in the M2M system,or may be another management entity device.

In a RESTful architecture, the application server may be aninfrastructure node-application entity (IN-AE for short hereinafter), anapplication service node-application entity (ASN-AE for shorthereinafter), an application dedicated node-application entity (ADN-AEfor short hereinafter), or a middle node-application entity (MN-AE forshort hereinafter). The managed object device may be an infrastructurenode-common service entity (IN-CSE for short hereinafter), a middlenode-common service entity (MN-CSE for short hereinafter), or anapplication service node-common service entity (ASN-CSE for shorthereinafter). In the RESTful architecture, a participant in atransaction includes one AE and multiple CSEs, where the AE is anapplication server in this application, and the CSEs are managed objectdevices in this application.

In addition, it should be noted that, one managed object devicecorresponds to only one to-be-operated resource, that is, identifiers ofto-be-operated resources included in all transaction resource creationrequests received by the managed object device are a same identifier.Different managed object devices correspond to different to-be-operatedresources.

FIG. 1 is a schematic flowchart of Embodiment 1 of a method forexecuting distributed transaction resources according to the presentinvention. This embodiment of the present invention relates to aspecific process in which managed object devices simultaneously executemultiple transaction resources in a transaction of an applicationserver, that is, a scenario in which for to-be-operated resources onmanaged object devices in an M2M system, there is no transactionresource of another transaction currently. As shown in FIG. 1, themethod includes the following steps.

S101. A first managed object device receives a first transactionresource creation request sent by an application server for a firsttransaction, where the first transaction resource creation requestincludes an identifier of a first to-be-operated resource, a firstexecution time, and a first to-be-executed operation.

S102. A second managed object device receives a second transactionresource creation request sent by the application server for the firsttransaction, where the second transaction resource creation requestincludes an identifier of a second to-be-operated resource, a secondexecution time, and a second to-be-executed operation, and the firstexecution time and the second execution time are the same.

Specifically, the application server sends the first transactionresource creation request for the first transaction to the first managedobject device and the second transaction resource creation request forthe first transaction to the second managed object device separately,that is, both a first transaction resource and a second transactionresource belong to the first transaction of the application server. Thefirst transaction resource creation request includes the identifier ofthe first to-be-operated resource, the first execution time, and thefirst to-be-executed operation. The second transaction resource creationrequest includes the identifier of the second to-be-operated resource,the second execution time, and the second to-be-executed operation. Thefirst execution time and the second execution time are the same.Optionally, the first to-be-executed operation and the secondto-be-executed operation may be the same or may be different. Inaddition, the first to-be-executed operation or the secondto-be-executed operation may be reflected in a primitive form, or may bereflected in another manner.

S103. The first managed object device successfully creates a firsttransaction resource of the first transaction according to the firsttransaction resource creation request, and the second managed devicesuccessfully creates a second transaction resource of the firsttransaction according to the second transaction resource creationrequest, where the first transaction resource includes the firstexecution time and the first to-be-executed operation, and the secondtransaction resource includes the second execution time and the secondto-be-executed operation.

It should be noted that, operations executed by the first managed deviceand the second managed object device are similar. Therefore, in all ofthe following technical solutions, the first managed object device isused as a described object. For the operation executed by the secondmanaged object device, refer to the operation executed by the firstmanaged object device. For the process of creating the secondtransaction resource by the second managed object device, refer to theprocess of creating the first transaction resource by the first managedobject device.

Specifically, the first managed object device determines, according toinformation such as the first execution time and the firstto-be-executed operation that are carried in the first transactionresource creation request, whether the first transaction resource can becreated successfully. The first to-be-executed operation includesinformation such as an initiator of a request, an identifier of arequested target resource, and specific content that is requested.

Optionally, the first managed object device may determine, according tothe information included in the first to-be-executed operation, whetherthe first transaction resource creation request meets a transactionresource creation condition. Specifically, the condition may includecontent of the following (1) to (4): (1) The first managed object devicechecks, according to “the identifier of the requested target resource”included in the first to-be-executed operation, whether the targetresource requested for the first to-be-executed operation is the firstto-be-operated resource. (2) The first managed object device checks,according to “the initiator of the request” included in the firstto-be-executed operation, whether the initiator (namely, the applicationserver) has enough rights to initiate the first transaction resourcecreation request. (3) The first managed object device checks, accordingto “the requested content” included in the first to-be-executedoperation, whether the requested content can be executed for the firstto-be-operated resource. For example, the first managed object devicechecks, by checking whether an attribute included in the firstto-be-executed operation is within an allowed attribute range of thefirst managed object device, whether the requested content can beexecuted for the first to-be-operated resource. (4) The first managedobject device checks, according to the first execution time andarrangements of work and sleep periods of the first managed objectdevice, whether execution of the first to-be-executed operation carriedin the first transaction resource creation request, at a time specifiedby the first execution time, can be ensured.

If the foregoing four items are all checked successfully, it indicatesthat the first transaction resource creation request meets thetransaction resource creation condition, and the first managed objectdevice can successfully create the first transaction resource accordingto the first transaction resource creation request. Based on a featureof a RESTful architecture, the created first transaction resourceincludes three attributes, namely, a state of the first transactionresource, the first execution time, and the first to-be-executedoperation (correspondingly, the second transaction resource includesthree attributes, namely, a state of the second transaction resource,the second execution time, and the second to-be-executed operation).

It should be noted that, the first transaction resource includes threeattributes, namely, the state, the execution time, and theto-be-executed operation. The state indicates the state of the currenttransaction resource. The state may be a reserved state, or may be asemi-reserved state. The reserved state means that the managed objectdevice can ensure successful execution of the to-be-executed operationin the transaction resource when the execution time arrives, that is,the managed object device has checked various conditions required forexecuting the transaction resource, including an access right, attributeconsistency, and the like. The semi-reserved state is a general state oftransaction resources in a transaction resource queue, that is, whetherthe managed object device can successfully execute the transactionresource depends on a state of the first to-be-operated resource afterone or more transaction resources in the transaction resource queue areexecuted. The execution time (indicated by Texec) indicates theexecution time of the current transaction resource, and is used toinstruct the managed object device to execute the to-be-executedoperation in the transaction resource when the execution time arrives.The to-be-executed operation (indicated by a Primitive) indicates ato-be-executed request, that is, including all information required forprocessing the to-be-operated resource on the managed object device.

In addition, the transaction resource is associated with theto-be-operated resource on the managed object device, that is, thetarget resource requested for the to-be-executed operation in thetransaction resource is the to-be-operated resource. A manner ofassociating the transaction resource with the to-be-operated resourcemay be that an identifier of the transaction resource is an attribute ofthe to-be-operated resource, or may be that the transaction resource isa sub-resource of the to-be-operated resource. Specifically, theto-be-operated resource may include an identifier of one or moretransaction resources, or an identifier of a transaction resource maydirectly include the identifier of the to-be-operated resource.

S104. The first managed object device sends a response indicative ofsuccessful creation of the first transaction resource of the firsttransaction to the application server, and the second managed objectdevice sends a response indicative of successful creation of the secondtransaction resource of the first transaction to the application server.

Specifically, after the first managed object device successfully createsthe first transaction resource, the first managed object device sendsthe response indicative of successful creation of the first transactionresource of the first transaction to the application server. In a timeperiod in which the first managed object device waits for arrival of thefirst execution time, optionally, the first managed object devicedetermines whether a processing request sent by the application serverfor the first transaction resource of the first transaction is received.Because one transaction on the application server includes multipletransaction resources, the application server sends differenttransaction resource creation requests to multiple managed objectdevices, so as to create transaction resources that belong to onetransaction on the managed object devices. In this embodiment, if thesecond managed object device does not successfully create the secondtransaction resource, the second managed object device sends a responseindicative of unsuccessful creation of the second transaction resourceto the application server. After receiving the response indicative ofcreation failure of the second transaction resource, the applicationserver sends the processing request for the first transaction resourceof the first transaction to the first managed object device, so as toinstruct the first managed object device to delete or update the firsttransaction resource that is created successfully. If the second managedobject device creates the second transaction resource successfully, thesecond managed object device sends the response indicative of successfulcreation of the second transaction resource of the first transaction tothe application server. Therefore, the application server does not sendthe processing request for the first transaction resource of the firsttransaction to the first managed object device.

S105. When the first execution time arrives, the first managed objectdevice and the second managed device respectively execute the operationsto be executed by the devices.

Specifically, when the first execution time arrives, if the firstmanaged object device has not received the processing request sent bythe application server for the first transaction resource of the firsttransaction, it indicates that the second transaction resource is alsocreated successfully on the second managed object device in the M2Msystem. Therefore, the first managed object device executes, accordingto the first to-be-executed operation in the created first transactionresource, the first to-be-executed operation on the first to-be-operatedresource indicated by the identifier of the first to-be-operatedresource. Further, because the second transaction resource is alsocreated successfully on the second managed object device in the M2Msystem, and the second managed object device has not received aprocessing request sent by the application server for the secondtransaction resource of the first transaction, either, the secondmanaged object device may also execute, at the second execution time,the second to-be-executed operation on the second to-be-operatedresource indicated by the identifier of the second to-be-operatedresource. That is, the first managed object device and the secondmanaged object device simultaneously execute the first to-be-executedoperation and the second to-be-executed operation respectively, that is,simultaneously execute the transaction resources included in the sametransaction.

For better describing the technical solution of this embodiment of thepresent invention, herein an example of intelligent irrigation in thebackground is used for description.

In the example of intelligent irrigation, an application server is anetwork application registered with an M2M platform, and managed objectdevices are valves distributed in different farmland. Referring to anM2M network architecture for intelligent irrigation shown in FIG. 2, theM2M system includes one application server and three valves. A valve 1is a first managed object device, and a valve 2 and a valve 3 are bothsecond managed object devices.

The application server sends transaction resource creation requests tothe valve 1, the valve 2, and the valve 3 respectively. A transactionresource creation request sent to the valve 1 is a first transactionresource creation request. A transaction resource creation request sentto the valve 2 is a second transaction resource creation request. Atransaction resource creation request sent to the valve 3 is anothersecond transaction resource creation request. Execution times in thetransaction resource creation requests sent by the application server tothe three valves are all 12:00, and the transaction resource creationrequests respectively include requests for adjusting different valves.The first transaction resource creation request sent to the valve 1 is arequest for adjusting an opening degree of the valve 1 to 20% (namely, afirst to-be-executed operation). The second transaction resourcecreation request sent to the valve 2 is a request for adjusting anopening degree of the valve 2 to 30% (namely, a second to-be-executedoperation). The second transaction resource creation request sent to thevalve 3 is a request for adjusting an opening degree of the valve 3 to40% (namely, another second to-be-executed operation).

Using the valve 1 as an example (for operations executed by the valve 2and the valve 3, refer to operations executed by the valve 1), the valve1 first checks whether the application server has a right to create afirst transaction resource, and then checks the first to-be-executedoperation included in the first transaction resource creation request,where content of the first to-be-executed operation is to adjust thevalve 1 to 20%. The valve 1 further checks whether the applicationserver has a right to adjust a to-be-operated resource on the valve 1,and checks whether 20% is within an adjustment range of the valve.Finally, the valve 1 concludes, according to a first execution timeprovided in the first transaction resource creation request and a sleeptime of the valve 1, that the first transaction resource can be createdsuccessfully, that is, the valve 1 may ensure that the valve 1 isadjusted to 20% of full opening of the valve 1 at 12:00. In thisexample, because the valve 1 creates a transaction resource for thefirst time, that is, the to-be-operated resource of the valve 1 does nothave a corresponding transaction resource queue, the valve 1 sets acurrent state of the first transaction resource to a reserved state,adds the state to a response indicative of successful creation of thefirst transaction resource, and sends the response to the applicationserver.

The valve 2 and the valve 3 may execute similar steps. In this example,it is assumed that the valve 2 and the valve 3 can also ensure that thevalves are adjusted to corresponding values at 12:00. Therefore,transaction resources created by the three valves are all in thereserved state. In this embodiment, because the three valves all returnresponses about successful creation of transaction resources, theapplication server does not initiate any request in a time period ofwaiting for arrival of the execution time.

When the execution time specified in the transaction resources createdby the three valves arrives, that is, when the time 12:00 arrives, thethree valves simultaneously execute content of the operations to beexecuted by the valves. That is, the valve 1 adjusts its opening degreeto 20%, the valve 2 adjusts its opening degree to 30%, and the valve 3adjusts its opening degree to 40%.

In this embodiment of the present invention, transaction resourcecreation requests sent to multiple managed object devices carry a sameexecution time, so that when it is determined that transaction resourcesare created successfully and the execution time arrives, the multiplemanaged object devices simultaneously execute the transaction resourcescreated by the managed object devices, thereby ensuring that thetransaction resources are executed simultaneously. In addition, in thisembodiment of the present invention, to ensure that the transactionresources are executed simultaneously, an application server needs tosend only one transaction resource creation request to a managed objectdevice. Therefore, signaling overheads of the application server arereduced.

FIG. 3 is a schematic flowchart of Embodiment 2 of a method forexecuting distributed transaction resources according to the presentinvention. Based on the foregoing embodiment, the method used in thisembodiment is a process in which the first managed object devicedetermines that a third transaction resource of a second transactionfails to be created, and sends a response indicative of unsuccessfulcreation of the third transaction resource of the second transaction tothe application server. as shown in FIG. 3, the method further includesthe following steps.

S201. The first managed object device receives a third transactionresource creation request sent by the application server for a secondtransaction, where the third transaction resource creation requestincludes the identifier of the first to-be-operated resource, a thirdexecution time, and a third to-be-executed operation.

S202. The second managed object device receives a fourth transactionresource creation request sent by the application server for the secondtransaction, where the fourth transaction resource creation requestincludes the identifier of the second to-be-operated resource, a fourthexecution time, and a fourth to-be-executed operation, and the thirdexecution time and the fourth execution time are the same.

Specifically, the application server sends the third transactionresource creation request for the second transaction to the firstmanaged object device and the fourth transaction resource creationrequest for the second transaction to the second managed object devicerespectively. The third transaction resource creation request includesthe identifier of the first to-be-operated resource, the third executiontime, and the third to-be-executed operation. The fourth transactionresource creation request includes the identifier of the secondto-be-operated resource, the fourth execution time, and the fourthto-be-executed operation. The third execution time and the fourthexecution time are the same. Optionally, the third to-be-executedoperation and the fourth to-be-executed operation may be the same or maybe different. In addition, the third to-be-executed operation or thefourth to-be-executed operation may be reflected in a primitive form, ormay be reflected in another manner.

S203. The first managed object device determines that a thirdtransaction resource of the second transaction fails to be createdaccording to the third transaction resource creation request, and sendsa response indicative of unsuccessful creation of the third transactionresource of the second transaction to the application server.

S204. The second managed device successfully creates a fourthtransaction resource of the second transaction according to the fourthtransaction resource creation request, and sends a response indicativeof successful creation of the fourth transaction resource of the secondtransaction to the application server, where the response indicative ofsuccessful creation of the fourth transaction resource carries anidentifier of the fourth transaction resource.

It should be noted that, operations executed by the first managed deviceand the second managed object device are similar. Therefore, in all ofthe following technical solutions, the first managed object device isused as a described object. For the operation executed by the secondmanaged object device, refer to the operation executed by the firstmanaged object device. For the process of creating the fourthtransaction resource by the second managed object device, refer to theprocess of creating the third transaction resource by the first managedobject device.

Specifically, the first managed object device determines, according toinformation such as the third execution time and the thirdto-be-executed operation carried in the third transaction resourcecreation request, whether the third transaction resource can be createdsuccessfully. The third to-be-executed operation includes a request forthe first to-be-operated resource, where the request may includeinformation such as an initiator of the request, an identifier of arequested target resource, and specific content that is requested.

Optionally, the first managed object device may determine, according tothe information included in the third to-be-executed operation, whetherthe third transaction resource creation request meets a transactionresource creation condition. The condition may specifically includecontent of the following (1) to (4): (1) The first managed object devicechecks, according to “the identifier of the requested target resource”included in the third to-be-executed operation, whether the targetresource requested for the third to-be-executed operation is the firstto-be-operated resource. (2) The first managed object device checks,according to “the initiator of the request” included in the thirdto-be-executed operation, whether the initiator (namely, the applicationserver) has enough rights to initiate the request. (3) The first managedobject device checks, according to “the requested content” included inthe third to-be-executed operation, whether the requested content can beexecuted for the first to-be-operated resource. (4) The first managedobject device checks, according to the third execution time andarrangements of work and sleep periods of the first managed objectdevice, whether execution of the third to-be-executed operation carriedin the third transaction resource creation request, at a time specifiedby the third execution time, can be ensured.

If any one of the foregoing four items fails to be checked, it indicatesthat the third transaction resource creation request does not meet thetransaction resource creation condition. The first managed object devicedetermines that the third transaction resource fails to be created, andsends the response indicative of unsuccessful creation of the thirdtransaction resource to the application server.

Further, the second managed device successfully creates the fourthtransaction resource of the second transaction according to the fourthtransaction resource creation request (for details, refer to the processof creating the third transaction resource), and sends the responseindicative of successful creation of the fourth transaction resource ofthe second transaction to the application server, where the responseindicative of successful creation of the fourth transaction resourcecarries the identifier of the fourth transaction resource.

After the application server receives the response that is sent by thefirst managed object device and that is indicative of unsuccessfulcreation of the third transaction resource of the second transaction andthe response that is sent by the second managed object device and thatis indicative of successful creation of the fourth transaction resourceof the second transaction, the application server determines to send aprocessing request for the fourth transaction resource of the secondtransaction to the second managed object device that successfullycreates the fourth transaction resource, where the processing requestfor the fourth transaction resource of the second transaction carriesthe identifier of the fourth transaction resource.

S205. The second managed object device that sends the responseindicative of successful creation of the fourth transaction resource tothe application server receives a processing request sent by theapplication server for the fourth transaction resource of the secondtransaction, where the processing request for the fourth transactionresource of the second transaction carries the identifier of the fourthtransaction resource.

Specifically, the processing request for the fourth transaction resourceof the second transaction may be a deletion request for deleting thefourth transaction resource, or may be an update request for updatingthe fourth execution time in the fourth transaction resource, so thatthe second managed object device obtains a new fourth transactionresource (when the first managed object device determines that the thirdexecution time in the third transaction resource creation request is notappropriate, the first managed object device sends a response indicativeof unsuccessful creation of the third transaction resource, where theresponse carries the updated third execution time; therefore, theapplication server sends a processing request that carries the updatedthird execution time to the second managed object device; certainly, thefirst managed object device may also create a new third transactionresource according to the updated third execution time).

S206. The second managed object device that sends the responseindicative of successful creation of the fourth transaction resource tothe application server processes the created fourth transaction resourceaccording to the identifier of the fourth transaction resource.

Specifically, after the second managed object device that sends theresponse indicative of successful creation of the fourth transactionresource to the application server receives the processing request sentby the application server for the fourth transaction resource of thesecond transaction, the second managed object device processes,according to the identifier of the fourth transaction resource carriedin the processing request, the fourth transaction resource that isalready successfully created on the second managed object device.

Optionally, the second managed object device may delete the fourthtransaction resource on the second managed object device to ensureatomicity of the second transaction (because the third transactionresource fails to be created, and the second transaction itself cannotbe executed successfully, the fourth transaction resource that alsobelongs to the second transaction should be deleted even if it iscreated successfully).

Optionally, the time of executing the fourth to-be-executed operation inthe fourth transaction resource on the second managed object device maybe updated, so that the time of executing the third to-be-executedoperation in the new third transaction resource by the first managedobject device is consistent with the time of executing the fourthto-be-executed operation in the new fourth transaction resource by thesecond managed object device. In addition, before the updated thirdexecution time arrives, the application server does not send anyprocessing request to the first managed object device and the secondmanaged object device. Therefore, the first managed object device andthe second managed object device can execute the transaction resourcesincluded in the same transaction.

In the method for executing distributed transaction resources accordingto this embodiment of the present invention, a first managed objectdevice and a second managed object device respectively receive a thirdtransaction resource creation request and a fourth transaction resourcecreation request that are sent by an application server and carry a sameexecution time; the second managed object device determines, accordingto a fourth execution time in the fourth transaction resource creationrequest, that a fourth transaction resource is created successfully, andreceives, before the fourth execution time arrives, a processing requestsent by the application server for the fourth transaction resource of asecond transaction; and the second managed object device processes thecreated fourth transaction resource according to the processing request.In the method provided by this embodiment of the present invention, thesecond managed object device can ensure, according to the processingrequest sent by the application server for the fourth transactionresource of the second transaction (when the processing request is anupdate request), that a time of executing the updated fourth transactionresource by the second managed object device is the same as a time atwhich the first managed object device executes a new third transactionresource created by the first managed object device, that is, it isensured that the first managed object device and the second managedobject device can simultaneously execute operations to be executed bythe devices. Therefore, simultaneous execution of transaction resourcesis ensured.

Based on the foregoing embodiment shown in FIG. 3, in a first possibleimplementation manner of this embodiment of the present invention, thisembodiment of the present invention relates to a specific scenario inwhich a managed object device executes multiple transaction resourcesincluded in one transaction only and the execution fails (that is, theexecution of the transaction fails), that is, a scenario in which forthe first to-be-operated resource on the first managed object device inthe M2M system, no transaction resource of another transaction isassociated currently. The foregoing S203 may be specifically as follows:

If the first managed object device determines, according to theinformation included in the third to-be-executed operation, that thethird transaction resource creation request does not meet the content of(1) in the foregoing transaction resource creation condition, the firstmanaged object device determines, according to the third transactionresource creation request, that the third transaction resource fails tobe created, and sends the response indicative of unsuccessful creationof the third transaction resource of the second transaction to theapplication server, so as to notify the application server that thethird transaction resource cannot be created successfully.

If the first managed object device determines, according to theinformation included in the third to-be-executed operation, that thethird transaction resource creation request does not meet the content ofany one of (2) to (4) in the foregoing transaction resource creationcondition, the first managed object device determines, according to thethird transaction resource creation request, that the third transactionresource fails to be created, and sends the response indicative ofunsuccessful creation of the third transaction resource to theapplication server, where the response carries the updated thirdexecution time, so as to notify the application server that the currentthird execution time is not appropriate, but the first managed objectdevice uses the updated third execution time carried in the responseindicative of unsuccessful creation of the third transaction resource,and the third transaction resource can be created successfully.

For better describing the technical solution of this embodiment, hereinthe foregoing example of intelligent irrigation is still used fordescription.

The application server sends transaction resource creation requests tothe valve 1, the valve 2, and the valve 3 respectively. A transactionresource creation request sent to the valve 1 is a third transactionresource creation request; a transaction resource creation request sentto the valve 2 is a fourth transaction resource creation request; atransaction resource creation request sent to the valve 3 is anotherfourth transaction resource creation request. Execution times in thetransaction resource creation requests sent by the application server tothe three valves are all 12:00, and the transaction resource creationrequests respectively include requests for adjusting different valves.The third transaction resource creation request sent to the valve 1 is arequest for adjusting an opening degree of the valve 1 to 20%; thefourth transaction resource creation request sent to the valve 2 is arequest for adjusting an opening degree of the valve 2 to 30%; thefourth transaction resource creation request sent to the valve 3 is arequest for adjusting an opening degree of the valve 3 to 40%.

Using the valve 1 as an example (for operations executed by the valve 2and the valve 3, refer to the valve 1), the valve 1 first checks whetherthe application server has a right to create a third transactionresource, and then checks a third to-be-executed operation included inthe third transaction resource creation request, where content of thethird to-be-executed operation is to adjust the valve 1 to 20%; thevalve 1 further checks whether the application server has a right toadjust the to-be-operated resource on the valve 1, and checks whether20% complies with the adjustment range of the valve; finally, the valve1 concludes, according to a third execution time provided in the thirdtransaction resource creation request and a sleep time of the valve 1,that the third transaction resource cannot be created successfullybecause it does not comply with the content of (4) but can be createdsuccessfully at 12:01. Therefore, the valve 1 sends a responseindicative of unsuccessful creation of the third transaction resource tothe application server, where the response carries the updated thirdexecuted time (namely, 12:01). In this example, assuming that fourthtransaction resources of the valve 2 and the valve 3 can be createdsuccessfully, that is, the fourth transaction resource creation requestsreceived by the valve 2 and the valve 3 comply with the content of theforegoing (1) to (4), the valve 2 and the valve 3 send responses aboutsuccessful creation of corresponding transaction resources to theapplication server, where the responses carry identifiers of the fourthtransaction resources respectively created by the valve 2 and the valve3, so as to notify the application server that the fourth transactionresources of the valve 2 and the valve 3 are created successfully.

Because currently the application server receives the response sent bythe valve 1 about unsuccessful creation of the third transactionresource, and the response carries the updated third execution time, theapplication server sends a processing request for the fourth transactionresource of a second transaction to the valve 2 and the valve 3, wherethe processing request may be an update request that carries the updatedthird execution time and the identifier of the fourth transactionresource. Optionally, the update request may further carry a fourthto-be-executed operation; in addition, the application server furthersends a new third transaction resource creation request to the valve 1,where the new third transaction resource creation request carries theupdated third execution time, and optionally, may further carry thethird to-be-executed operation.

When the valve 1 receives the new third transaction resource creationrequest, the valve 1 may also execute the content of (1) to (4). Becausethe valve 1 has determined that the third to-be-executed operationcomplies with the content of (1) to (3), the third to-be-executedoperation carried in the new third transaction resource creation requestis not changed, and the valve 1 may directly determine whether theupdated third execution time complies with the content of (4); inaddition, because the updated third execution time is a time recommendedby the valve 1 to the application server according to a working state ofthe valve 1, the updated third execution time is a time that may ensuresuccessful creation of the third transaction resource. The valve 2 andthe valve 3 also execute the content of the foregoing (1) to (4) whenreceiving the update request sent by the application server. Because thevalve 2 and the valve 3 have respectively determined that their fourthto-be-executed operation complies with the content of (1) to (3), andthe fourth to-be-executed operation carried in the update request is notchanged, the valve 2 and the valve 3 may also directly determine whetherthe updated third execution time complies with the content of (4).Assuming that the valve 2 determines that the updated third executiontime in the received update request complies with the content of (4),that is, the fourth transaction resource on the valve 2 may be updatedsuccessfully, and assuming that the valve 3 determines that the updatedthird execution time in the received update request does not comply withthe content of (4), that is, the valve 3 determines that the valve 3 hasentered a sleep state when the updated third execution time arrives, anda time of resuming work is uncertain, the fourth transaction resource onthe valve 3 cannot be created successfully, and the valve 3 alreadycannot support creation of any transaction resource locally. Therefore,the valve 3 sends a response indicative of unsuccessful creation of thefourth transaction resource of the second transaction to the applicationserver, notifying the application server of the case that the valve 3already cannot support creation of any transaction resource.

In this case, the new third transaction resource on the valve 1 has beencreated successfully, and the fourth transaction resource on the valve 2has been updated successfully, but before the updated third executiontime arrives, because the application server has received the responsesent by the valve 3 about unsuccessful creation of the fourthtransaction resource of the second transaction, and learned that thevalve 3 already cannot support creation of any transaction resource, theapplication server sends deletion requests to the valve 1 and the valve2, so as to delete the new third transaction resource on the valve 1 andthe updated fourth transaction resource on the valve 2, and ensureatomicity of the transaction. Therefore, the current second transactionon the applications server cannot be executed successfully.

When the valve 1 receives the new third transaction resource creationrequest, if the valve 1 creates the new third transaction resourcesuccessfully according to the new third transaction resource creationrequest, and the valve 2 and the valve 3 update the fourth transactionresources successfully according to the updated third execution time inthe update request, and before the updated third execution time arrives,none of the valve 1, the valve 2, and the valve 3 receives theprocessing request sent by the application server, when the updatedthird execution time arrives, the valve 1, the valve 2, and the valve 3execute the new third transaction resource and the updated fourthtransaction resources simultaneously.

In the method for executing distributed transaction resources accordingto this embodiment of the present invention, when a first managed objectdevice fails to create a third transaction resource according to a thirdtransaction resource creation request, the first managed object devicesends a response indicative of unsuccessful creation of the thirdtransaction resource of a second transaction to an application server,where the response indicative of unsuccessful creation of the thirdtransaction resource carries the updated third execution time, so thatthe application server sends a new third transaction resource creationrequest to the first managed object device, so as to create a new thirdtransaction resource. In addition, the application server sends aprocessing request for the fourth transaction resource of the secondtransaction to a second managed object device; when the processingrequest is an update request that carries the updated third executiontime, the first managed object device and the second managed objectdevice can process, according to the updated third execution time,transaction resources created by the devices respectively, and ensurethat their current transaction resources can be executed simultaneouslywhen the updated third execution time arrives.

In an actual M2M system, for a to-be-operated resource on a managedobject device, usually a new transaction resource creation request issent again when an existing transaction resource is not executed yet,and in this case, a transaction resource queue for the to-be-operatedresource is formed. Therefore, based on the foregoing embodiment shownin FIG. 3, in a second possible implementation manner of this embodimentof the present invention, this embodiment of the present invention isapplied to a scenario of processing concurrent transaction resources ona managed object device, that is, a scenario in which a transactionresource queue exists on the managed object device. This embodimentrelates to a specific process in which the first managed object devicefails to create the third transaction resource in a first transactionresource queue. Referring to FIG. 4, the foregoing S203 may specificallyinclude the following steps.

S301. The first managed object device determines that a firsttransaction resource queue exists on the first managed object device,where the first transaction resource queue includes at least onetransaction resource.

Because the operations executed by the first managed object device andthe second managed object device are similar, in the following technicalsolution, the first managed object device is used as a main describedobject. For an operation executed by the second managed object deviceafter the fourth transaction resource creation request is received,refer to the operation executed by the first managed object device afterthe third transaction resource creation request is received.

Specifically, after the first managed object device receives the thirdtransaction resource creation request sent by the application server forthe second transaction, the first managed object device determines,according to the identifier of the first to-be-operated resource that iscarried in the third transaction resource creation request, whether thefirst transaction resource queue corresponding to the firstto-be-operated resource exists. The first transaction resource queueincludes at least one transaction resource, and transaction resources inthe first transaction resource queue are arranged according to anexecution time of each transaction resource in the first transactionresource queue. If the first managed object device determines that nofirst transaction resource queue exists on the first managed objectdevice, the first managed object device may perform execution accordingto the technical solution in Embodiment 1 shown in FIG. 1 or in thefirst possible implementation manner of the embodiment shown in FIG. 3.Details are not described again herein. If it is determined that thefirst transaction resource queue exists, step 302 is executed.

S302. The first managed object device determines, according to the thirdexecution time and a state of the first to-be-operated resource, thatthe third transaction resource does not meet a preset resource creationcondition.

Specifically, when the first managed object device determines, accordingto the identifier of the first to-be-operated resource, that the firsttransaction resource queue exists on the first managed object device,the first managed object device performs arrangement and comparisonaccording to the third execution time in the third transaction resourcecreation request and the execution time of each transaction resource inthe first transaction resource queue, and determines a position forinserting the third transaction resource in the first transactionresource queue. It should be noted that, the first managed object devicecurrently has not created the third transaction resource successfully.Herein the third transaction resource is a to-be-created transactionresource.

Further, the first managed object device may determine, according to thethird execution time and the state of the first to-be-operated resourceon the first managed object device, that the third transaction resourcedoes not meet the preset resource creation condition, that is, determinethat the third transaction resource fails to be created, and send theresponse indicative of unsuccessful creation of the third transactionresource of the second transaction to the application server. The stateof the first to-be-operated resource is specifically a state of thefirst to-be-operated resource after at least one transaction resource inthe first transaction resource queue is executed. That the first managedobject device determines that the third transaction resource does notmeet the preset resource creation condition may specifically include thefollowing two cases A and B.

A. The first managed object device determines, according to the thirdexecution time and the state of the first to-be-operated resource of thefirst managed object device, that the preset resource creation conditionis not met if the third execution time is updated to any time later thanthe execution time of each transaction resource in the first transactionresource queue. The first managed object device sends a first failureresponse to the application server.

Optionally, when one transaction resource included in the firsttransaction resource queue is in the reserved state, and a transactionresource located at a first position in the first transaction resourcequeue is in the reserved state, the first managed object devicedetermines, according to the third execution time and the state of thefirst to-be-operated resource, that the preset resource creationcondition is not met when the third execution time is updated to anytime later than the execution time of each transaction resource in thefirst transaction resource queue. Specifically, the following threecases a, b, and c may be included. It should be noted that, for detailsabout the preset resource creation condition, refer to content describedin a, b, and c. In addition, the preset resource creation condition isdifferent from the content of (1) to (4) in the foregoing embodiment.For example, in the following preset resource creation condition a, whenthe third transaction resource is located at the first position in thequeue, the first managed object device determines that the thirdtransaction resource cannot be executed successfully if the thirdtransaction resource is inserted in any other position in the firsttransaction resource queue. As long as this condition is met, the firstmanaged object device determines that the third transaction resourcefails to be created. However, for how to specifically determine whetherthe third transaction resource can be executed successfully when thethird transaction resource is located in any other position in the firsttransaction resource queue, a specific determining step may bedetermining according to the content of (1) to (4) in the foregoingembodiment.

a. If it is determined, according to the third execution time, that notransaction resource in the first transaction resource queue existsbefore the position for inserting the third transaction resource in thefirst transaction resource queue, and if the first managed object deviceupdates the third execution time of the third transaction resource toany time later than the execution time of each transaction resource inthe first transaction resource queue (that is, if the first managedobject device inserts the third transaction resource into any otherposition in the first transaction resource queue), the first managedobject device determines that the third transaction resource cannot beexecuted successfully when the third execution time arrives. That is,the first managed object device determines, according to the status ofthe first to-be-operated resource after any transaction resource in thefirst transaction resource queue is executed, that the third transactionresource cannot be switched to the reserved state. In this case, thefirst managed object device determines that the third transactionresource fails to be created, and sends the first failure response tothe application server, so that the application server sends theprocessing request for the fourth transaction resource of the secondtransaction to the second managed object device that receives the fourthtransaction resource creation request, where the processing request is adeletion request that carries the identifier of the fourth transactionresource, and the deletion request is used to delete the fourthtransaction resource successfully created on the second managed objectdevice.

It should be noted that, the transaction resource in this embodiment ofthe present invention cannot be executed successfully at the executiontime may also be understood to be that the transaction resource cannotbe switched to the reserved state. In addition, as described above, inthe case a, the foregoing state of the first to-be-operated resource isthe state of the first to-be-operated resource after a transactionresource in any position in the first transaction resource queue isexecuted.

b. If it is determined, according to the third execution time, thattransaction resources in the first transaction resource queue exist bothbefore and after the position for inserting the third transactionresource in the first transaction resource queue, the first managedobject device determines, according to the state of the firstto-be-operated resource after a transaction resource in a third positionis executed, whether the third transaction resource can be executedsuccessfully, where the third position is a previous position adjacentto the position for inserting the third transaction resource in thefirst transaction resource queue.

If the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, that the third transaction resource cannotbe executed successfully, and if the third execution time of the thirdtransaction resource is updated to any time later than the executiontime of each transaction resource in the first transaction resourcequeue (that is, when inserting the third transaction resource into anyother position in the first transaction resource queue), the firstmanaged object device determines that the third transaction resourcealso cannot be executed successfully. That is, based on the state afterany transaction resource in the first transaction resource queue isexecuted, the third transaction resource cannot be switched to thereserved state. In this case, the first managed object device determinesthat the third transaction resource fails to be created, and sends thefirst failure response to the application server, so that theapplication server sends the processing request for the fourthtransaction resource of the second transaction to the second managedobject device that receives the fourth transaction resource creationrequest, where the processing request is a deletion request that carriesthe identifier of the fourth transaction resource, and the deletionrequest is used to delete the fourth transaction resource successfullycreated on the second managed object device.

If the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, that the third transaction resource can beexecuted successfully, and determines, according to the state of thefirst to-be-operated resource after the third transaction resource isexecuted, that a transaction resource in a fourth position in the firsttransaction resource queue cannot be executed successfully (the fourthposition is a next position adjacent to the position for inserting thethird transaction resource in the first transaction resource queue), anddetermines to update the third execution time of the third transactionresource to any time later than the execution time of each transactionresource in the first transaction resource queue (that is, whendetermining that the third transaction resource is inserted into anyother position in the first transaction resource queue), the firstmanaged object device determines that the third transaction resourcealso cannot be executed successfully. That is, based on the state afterany transaction resource in the first transaction resource queue isexecuted, the third transaction resource cannot be switched to thereserved state. In this case, the first managed object device determinesthat the third transaction resource fails to be created, and sends thefirst failure response to the application server, so that theapplication server sends the processing request for the fourthtransaction resource of the second transaction to the second managedobject device that receives the fourth transaction resource creationrequest, where the processing request is a deletion request that carriesthe identifier of the fourth transaction resource, and the deletionrequest is used to delete the fourth transaction resource successfullycreated on the second managed object device.

As described above, in the case b, the foregoing state of the firstto-be-operated resource may be the state of the first to-be-operatedresource after the transaction resource in the third position isexecuted, or may be the state of the first to-be-operated resource afterthe third transaction resource is executed, or may be the state of thefirst to-be-operated resource after any transaction resource in thefirst transaction resource queue is executed. The status of the firstto-be-operated resource is determined according to different cases.

c. If it is determined, according to the third execution time, that atransaction resource in the first transaction resource queue existsbefore the position for inserting the third transaction resource in thefirst transaction resource queue, but no transaction resource in thefirst transaction resource queue exists after the inserting position,the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, whether the third transaction resource canbe executed successfully.

If the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, that the third transaction resource cannotbe executed successfully, and determines to update the third executiontime of the third transaction resource to any time later than theexecution time of each transaction resource in the first transactionresource queue (that is, when inserting the third transaction resourceinto any other position in the first transaction resource queue), thefirst managed object device determines that the third transactionresource also cannot be executed successfully. That is, based on thestate after any transaction resource in the first transaction resourcequeue is executed, the third transaction resource cannot be switched tothe reserved state. In this case, the first managed object devicedetermines that the third transaction resource fails to be created, andsends the first failure response to the application server, so that theapplication server sends the processing request for the fourthtransaction resource of the second transaction to the second managedobject device that receives the fourth transaction resource creationrequest, where the processing request is a deletion request that carriesthe identifier of the fourth transaction resource, and the deletionrequest is used to delete the fourth transaction resource successfullycreated on the second managed object device.

As described above, in the case c, the foregoing state of the firstto-be-operated resource may be the state of the first to-be-operatedresource after the transaction resource in the third position isexecuted, or may be the state of the first to-be-operated resource afterany transaction resource in the first transaction resource queue isexecuted. Content of the state of the first to-be-operated resource isdetermined according to different cases.

Optionally, when at least two transaction resources included in thefirst transaction resource queue are in the reserved state, the firstmanaged object device determines, according to the third execution timeand the state of the first to-be-operated resource, that the presetresource creation condition is not met when the third execution time isupdated to any time later than the execution time of each transactionresource in the first transaction resource queue. Specifically, thefollowing two cases d and e may be included. It should be noted that,for details about the preset resource creation condition, refer to thedetermining conditions described in d and e.

d. If the first managed object device determines, according to the stateof the first to-be-operated resource after the third transactionresource is executed, that none of other transaction resources in thereserved state in the first transaction resource queue after theposition for inserting the third transaction resource in the firsttransaction resource queue can be executed or that one of them cannot beexecuted successfully, and determines to update the third execution timeof the third transaction resource to any time later than the executiontime of each transaction resource in the first transaction resourcequeue (that is, when inserting the third transaction resource into anyother position in the first transaction resource queue), the firstmanaged object device determines, according to the state of the firstto-be-operated resource after the transaction resource in the any otherposition in the first transaction resource queue is executed, that noneof transaction resources in the reserved state after the any otherposition also cannot be executed successfully or that one of them cannotbe executed successfully. In this case, the first managed object devicedetermines that the third transaction resource fails to be created, andsends the first failure response to the application server, so that theapplication server sends the processing request for the fourthtransaction resource of the second transaction to the second managedobject device that receives the fourth transaction resource creationrequest, where the processing request is a deletion request that carriesthe identifier of the fourth transaction resource, and the deletionrequest is used to delete the fourth transaction resource successfullycreated on the second managed object device.

As described above, in the case d, the foregoing state of the firstto-be-operated resource may be the state of the first to-be-operatedresource after the third transaction resource is executed, or may be thestate of the first to-be-operated resource after the transactionresource in any other position in the first transaction resource queueis executed. Content of the state of the first to-be-operated resourceis determined according to different cases.

e. If the first managed object device determines, according to the stateof the first to-be-operated resource after the third transactionresource is executed, that any other transaction resource in thereserved state after the position for inserting the third transactionresource in the first transaction resource queue can be executedsuccessfully, the first managed object device further determines whetherany other transaction resource in the first transaction resource queueexists before the inserting position.

If another transaction resource in the first transaction resource queueexists before the position for inserting the third transaction resourcein the first transaction resource queue, the first managed object devicedetermines, according to the state of the first to-be-operated resourceafter any transaction resource in the other transaction resourcesexisting before the inserting position in the first transaction resourcequeue is executed, whether the third transaction resource can beexecuted successfully; and if not, the first managed object devicefurther determines, according to the state of the first to-be-operatedresource after the transaction resource in the third position in thefirst transaction resource queue is executed, whether the thirdtransaction resource can be executed successfully. If not, the firstmanaged object device further determines whether the third transactionresource can be executed successfully if the execution time of the thirdtransaction resource is updated to any time later than the executiontime of each transaction resource in the first transaction resource(that is, determining whether the third transaction resource can beexecuted successfully if the third transaction resource is inserted intoany other position in the first transaction resource queue). When thefirst managed object device determines that the third transactionresource cannot be executed successfully if the third transactionresource is inserted into the any other position in the firsttransaction resource queue, the first managed object device determinesthat the third transaction resource fails to be created, and sends thefirst failure response to the application server, so that theapplication server sends the processing request for the fourthtransaction resource of the second transaction to the second managedobject device that receives the fourth transaction resource creationrequest, where the processing request is a deletion request that carriesthe identifier of the fourth transaction resource, and the deletionrequest is used to delete the fourth transaction resource successfullycreated on the second managed object device.

As described above, in the case e, the foregoing state of the firstto-be-operated resource may be the state of the first to-be-operatedresource after the third transaction resource is executed, or may be thestate of the first to-be-operated resource after any transactionresource previous to the foregoing determined inserting position isexecuted, or may be the state of the first to-be-operated resource afterthe transaction resource in the third position is executed, or may bethe state of the first to-be-operated resource after the transactionresource in any other position in the first transaction resource queueis executed. Content of the state of the first to-be-operated resourceis determined according to different cases.

In summary, all the foregoing five cases a, b, c, d, and e are cases inwhich the first managed object device determines, according to the thirdexecution time and the state of the first to-be-operated resource, thatthe preset resource creation condition is not met when the thirdexecution time of the third transaction resource is updated to any timelater than the execution time of each transaction resource in the firsttransaction resource queue.

B. The first managed object device determines, according to the thirdexecution time and the state of the first to-be-operated resource of thefirst managed object device, that the third transaction resource doesnot meet the preset resource creation condition. In this case, the firstmanaged object device updates the third execution time to a time laterthan an execution time of a transaction resource in the firsttransaction resource queue according to the preset resource creationcondition (that is, the time causes the third transaction resource tomeet the preset resource creation condition). The first managed objectdevice sends a second failure response carrying the updated thirdexecution time to the application server.

Optionally, when one transaction resource included in the firsttransaction resource queue is in the reserved state, and the transactionresource located at the first position in the first transaction resourcequeue is in the reserved state, the first managed object devicedetermines, according to the third execution time and the state of thefirst to-be-operated resource, that the preset resource creationcondition is met when the third execution time is updated to a timelater than an execution time of a transaction resource in the firsttransaction resource queue. Specifically the following three cases f, g,and h may be included. It should be noted that, for details about thepreset resource creation condition, refer to the determining conditionsdescribed in f, g, and h.

f. If it is determined, according to the third execution time, that notransaction resource in the first transaction resource queue existsbefore the position for inserting the third transaction resource in thefirst transaction resource queue, and the first managed object devicedetermines to update the third execution time of the third transactionresource to a time later than an execution time of a transactionresource in the first transaction resource queue (that is, if the firstmanaged object device determines that the third transaction resource isinserted into a position in the first transaction resource queue), thefirst managed object device determines, according to the state of thefirst to-be-operated resource after the transaction resource in theposition is executed, that the third transaction resource can beexecuted successfully. In this case, the first managed object devicedetermines that the third transaction resource fails to be created, andsends the second failure response that carries the updated thirdexecution time to the application server, so that the application serversends the processing request for the fourth transaction resource of thesecond transaction to the second managed object device that receives thefourth transaction resource creation request, where the processingrequest is an update request that carries the updated third executiontime and the identifier of the fourth transaction resource; therefore,the application server sends a new third transaction resource creationrequest that carries the updated third execution time to the firstmanaged object device, so as to create a new third transaction resource.The updated third execution time is a time of successfully creating thenew third transaction resource by the first managed object device in thefirst transaction resource queue.

As described above, the state of the first to-be-operated resource inthe case f may be the state of the first to-be-operated resource after atransaction resource in a position is executed if the third transactionresource is inserted into the position in the first transaction resourcequeue (execution of the transaction resource needs to ensure successfulexecution of the third transaction resource). Content of the state ofthe first to-be-operated resource is determined according to differentcases.

g. If it is determined, according to the third execution time, thattransaction resources in the first transaction resource queue exist bothbefore and after the position for inserting the third transactionresource in the first transaction resource queue, the first managedobject device determines, according to the state of the firstto-be-operated resource after the transaction resource in the thirdposition is executed, whether the third transaction resource can beexecuted successfully, where the third position is a previous positionadjacent to the position for inserting the third transaction resource inthe first transaction resource queue.

If the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, that the third transaction resource cannotbe executed successfully, and determines to update the third executiontime of the third transaction resource to a time later than an executiontime of a transaction resource in the first transaction resource queue(that is, when inserting the third transaction resource into a positionin the first transaction resource queue), the first managed objectdevice determines, according to the state of the first to-be-operatedresource after the transaction resource in the position is executed,that the third transaction resource can be executed successfully. Inthis case, the first managed object device determines that the thirdtransaction resource fails to be created, and sends the second failureresponse that carries the updated third execution time to theapplication server, so that the application server sends the processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that receives the fourth transactionresource creation request, where the processing request is an updaterequest that carries the updated third execution time and the identifierof the fourth transaction resource; therefore, the application serversends a new third transaction resource creation request that carries theupdated third execution time to the first managed object device, so asto create a new third transaction resource. The updated third executiontime is a time of successfully creating the new third transactionresource by the first managed object device in the first transactionresource queue.

If the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, that the third transaction resource can beexecuted successfully, and the first managed object device determines,according to the state of the first to-be-operated resource after thethird transaction resource is executed, that the transaction resource inthe fourth position in the first transaction resource queue cannot beexecuted successfully (the fourth position is a next position adjacentto the position for inserting the third transaction resource in thefirst transaction resource queue), and the first managed object deviceupdates the third execution time of the third transaction resource to atime later than an execution time of a transaction resource in the firsttransaction resource queue (that is, when inserting the thirdtransaction resource into a position in the first transaction resourcequeue), the first managed object device determines, according to thestate of the first to-be-operated resource after the transactionresource in the position is executed, that the third transactionresource can be executed successfully. In this case, the first managedobject device determines that the third transaction resource fails to beexecuted, and sends the second failure response that carries the updatedthird execution time to the application server, so that the applicationserver sends the processing request for the fourth transaction resourceof the second transaction to the second managed object device thatreceives the fourth transaction resource creation request, where theprocessing request is an update request that carries the updated thirdexecution time and the identifier of the fourth transaction resource;therefore, the application server sends a new third transaction resourcecreation request that carries the updated third execution time to thefirst managed object device, so as to create a new third transactionresource. The updated third execution time is a time of successfullycreating the new third transaction resource by the first managed objectdevice in the first transaction resource queue.

As described above, the state of the first to-be-operated resource inthe case g may be the state of the first to-be-operated resource afterthe transaction resource in the third position is executed, or may bethe state of the first to-be-operated resource after the thirdtransaction resource is executed, or may be the state of the firstto-be-operated resource after a transaction resource in a position isexecuted if the third transaction resource is inserted into the positionin the first transaction resource queue (execution of the transactionresource needs to ensure successful execution of the third transactionresource). Content of the state of the first to-be-operated resource isdetermined according to different cases.

h. If it is determined, according to the third execution time, that atransaction resource in the first transaction resource queue existsbefore the position for inserting the third transaction resource in thefirst transaction resource queue, but no transaction resource in thefirst transaction resource queue exists after the inserting position,the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, whether the third transaction resource canbe executed successfully.

If the first managed object device determines, according to the state ofthe first to-be-operated resource after the transaction resource in thethird position is executed, that the third transaction resource cannotbe executed successfully, and determines to update the third executiontime of the third transaction resource to a time later than an executiontime of a transaction resource in the first transaction resource queue(that is, when inserting the third transaction resource into a positionin the first transaction resource queue), the first managed objectdevice determines, according to the state of the first to-be-operatedresource after the transaction resource in the position is executed,that the third transaction resource can be executed successfully. Inthis case, the first managed object device determines that the thirdtransaction resource fails to be created, and sends the second failureresponse that carries the updated third execution time to theapplication server, so that the application server sends the processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that receives the fourth transactionresource creation request, where the processing request is an updaterequest that carries the updated third execution time and the identifierof the fourth transaction resource; therefore, the application serversends a new third transaction resource creation request that carries theupdated third execution time to the first managed object device, so asto create a new third transaction resource. The updated third executiontime is a time of successfully creating the new third transactionresource by the first managed object device in the first transactionresource queue.

It should be noted that, the state of the first to-be-operated resourcein the case h may be the state of the first to-be-operated resourceafter the transaction resource in the third position is executed, or maybe the state of the first to-be-operated resource after a transactionresource in a position is executed if the third transaction resource isinserted into the position in the first transaction resource queue(execution of the transaction resource needs to ensure successfulexecution of the third transaction resource). Content of the state ofthe first to-be-operated resource is determined according to differentcases.

Optionally, when at least two transaction resources included in thefirst transaction resource queue are in the reserved state, the firstmanaged object device determines, according to the third execution timeand the state of the first to-be-operated resource, that the presetresource creation condition is met when the third execution time isupdated to a time later than an execution time of a transaction resourcein the first transaction resource queue. Specifically, the following twocases i and j may be included. It should be noted that, for detailsabout the preset resource creation condition, refer to the determiningconditions described in i and j.

i. If the first managed object device determines, according to the stateof the first to-be-operated resource after the third transactionresource is executed, that none of other transaction resources in thereserved state in the first transaction resource queue after theposition for inserting the third transaction resource in the firsttransaction resource queue can be executed or that one of them cannot beexecuted successfully, and determines to update the third execution timeof the third transaction resource to a time later than an execution timeof a transaction resource in the first transaction resource queue (thatis, when inserting the third transaction resource into a position in thefirst transaction resource queue), all transaction resources in thereserved state after the time in the first transaction resource queuecan be executed successfully (that is, the first managed object devicedetermines, according to the state of the first to-be-operated resourceafter the transaction resource in the position is executed, that all thetransaction resources in the reserved state in the first transactionresource queue after the position can be executed successfully). In thiscase, the first managed object device determines that the thirdtransaction resource fails to be created, and sends the second failureresponse that carries the updated third execution time to theapplication server, so that the application server sends the processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that receives the fourth transactionresource creation request, where the processing request is an updaterequest that carries the updated third execution time and the identifierof the fourth transaction resource; therefore, the application serversends a new third transaction resource creation request that carries theupdated third execution time to the first managed object device, so asto create a new third transaction resource. The updated third executiontime is a time of successfully creating the new third transactionresource by the first managed object device in the first transactionresource queue.

It should be noted that, the state of the first to-be-operated resourcein the case i may be the state of the first to-be-operated resourceafter the third transaction resource is executed, or may be the state ofthe first to-be-operated resource after a transaction resource in aposition is executed if the third transaction resource is inserted intothe position in the first transaction resource queue (execution of thetransaction resource needs to ensure successful execution of all thetransaction resources in the reserved state in the first transactionresource queue after the position). Content of the state of the firstto-be-operated resource is determined according to different cases.

j. If the first managed object device determines, according to thecurrent state of the first to-be-operated resource after the thirdtransaction resource is executed, that any other transaction resource inthe reserved state after the position for inserting the thirdtransaction resource in the first transaction resource queue can beexecuted successfully, the first managed object device furtherdetermines whether any other transaction resource in the firsttransaction resource queue exists before the inserting position.

If another transaction resource in the first transaction resource queueexists before the position for inserting the third transaction resourcein the first transaction resource queue, the first managed object devicedetermines, according to the state of the first to-be-operated resourceafter any transaction resource in the other transaction resourcesexisting before the inserting position in the first transaction resourcequeue is executed, whether the third transaction resource can beexecuted successfully; and if not, the first managed object devicefurther determines, according to the state of the first to-be-operatedresource after the transaction resource in the third position in thefirst transaction resource queue is executed, whether the thirdtransaction resource can be executed successfully. If not, the firstmanaged object device further determines whether the third transactionresource can be executed successfully when the execution time of thethird transaction resource is updated to a time later than an executiontime of a transaction resource in the first transaction resource queue(that is, if the third transaction resource is inserted into a positionin the first transaction resource queue, the first managed object devicedetermines, according to the state of the first to-be-operated resourceafter the transaction resource in the position is executed, that thethird transaction resource can be executed successfully). In this case,the first managed object device determines that the third transactionresource fails to be created, and sends the second failure response thatcarries the updated third execution time to the application server, sothat the application server sends the processing request for the fourthtransaction resource of the second transaction to the second managedobject device that receives the fourth transaction resource creationrequest, where the processing request is an update request that carriesthe updated third execution time and the identifier of the fourthtransaction resource; therefore, the application server sends a newthird transaction resource creation request that carries the updatedthird execution time to the first managed object device, so as to createa new third transaction resource. The updated third execution time is atime of successfully creating the new third transaction resource by thefirst managed object device in the first transaction resource queue.

It should be noted that, the state of the first to-be-operated resourcein the case i may be the state of the first to-be-operated resourceafter the third transaction resource is executed, or may be the state ofthe first to-be-operated resource after any transaction resource in theother transaction resources existing before the position for insertingthe third transaction resource in the first transaction resource queueis executed, or may be the state of the first to-be-operated resourceafter the transaction resource in the third position is executed, or maybe the state of the first to-be-operated resource after a transactionresource in a position is executed if the third transaction resource isinserted into the position in the first transaction resource queue(execution of the transaction resource needs to ensure successfulexecution of the third transaction resource). Content of the state ofthe first to-be-operated resource is determined according to differentcases.

In summary, all the foregoing five cases f, g, h, i, and j are cases inwhich the first managed object device determines, according to the thirdexecution time and the state of the first to-be-operated resource, thatthe preset resource creation condition is met when the third executiontime of the third transaction resource is updated to a time later thanan execution time of any transaction resource in the first transactionresource queue.

Based on the foregoing embodiment shown in FIG. 3, in a third possibleimplementation manner of this embodiment of the present invention, thisembodiment of the present invention is also applied to a scenario ofprocessing concurrent transaction resources on a managed object device,that is, a scenario in which a transaction resource queue exists on themanaged object device. This embodiment relates to a specific process inwhich the second managed object device creates the fourth transactionresource successfully in a second transaction resource queue. Referringto FIG. 5, the foregoing S204 may specifically include the followingsteps.

S401. The second managed object device determines that a secondtransaction resource queue exists on the second managed object device,where the second transaction resource queue includes at least onetransaction resource.

Specifically, after receiving the fourth transaction resource creationrequest sent by the application server, the second managed object devicedetermines whether the second transaction resource queue exists. Thesecond transaction resource queue includes at least one transactionresource, and transaction resources in the second transaction resourcequeue are arranged according to an execution time of each transactionresource in the second transaction resource queue. If the second managedobject device determines that no second transaction resource queueexists on the second managed object device, the second managed objectdevice may perform execution according to the technical solution inEmbodiment 1 shown in FIG. 1 or in the first possible implementationmanner of the embodiment shown in FIG. 3. Details are not describedagain herein. If it is determined that the second transaction resourcequeue exists, step 402 is executed.

S402. The second managed object device determines, according to thefourth execution time and a state of the second to-be-operated resourceof the second managed object device, that the fourth transactionresource meets the preset resource creation condition, and creates thefourth transaction resource.

Specifically, when the second managed object device determines that thesecond transaction resource queue exists, the second managed objectdevice performs arrangement and comparison according to the fourthexecution time in the fourth transaction resource creation request andthe execution time of each transaction resource in the secondtransaction resource queue, and determines a position for inserting thefourth transaction resource in the second transaction resource queue. Itshould be noted that, the second managed object device currently has notcreated the fourth transaction resource successfully. Herein the fourthtransaction resource is a to-be-created transaction resource.

Further, the second managed object device determines, according to thefourth execution time and the state of the second to-be-operatedresource, that the fourth transaction resource meets the preset resourcecreation condition, creates the fourth transaction resource, and sendsthe response indicative of successful creation of the fourth transactionresource to the application server, where the response carries theidentifier of the fourth transaction resource. Specifically, thefollowing two cases C and D may be included.

C. When one transaction resource included in the second transactionresource queue is in the reserved state, and a transaction resourcelocated at a first position in the second transaction resource queue isin the reserved state, the second managed object device determines,according to the fourth execution time and the state of the secondto-be-operated resource, that the fourth transaction resource meets thepreset resource creation condition, and creates the fourth transactionresource. Specifically, the following two cases k and l may be included.It should be noted that, for details about the preset resource creationcondition, refer to the determining conditions described in k and l.

k. If it is determined, according to the fourth execution time, thattransaction resources in the second transaction resource queue existboth before and after the position for inserting the fourth transactionresource in the second transaction resource queue, the second managedobject device determines, according to the state of the secondto-be-operated resource after the transaction resource at the firstposition is executed, whether the fourth transaction resource can beexecuted successfully, where the first position is a previous positionadjacent to the position for inserting the fourth transaction resourcein the second transaction resource queue.

If the second managed object device determines, according to the stateof the second to-be-operated resource after the transaction resource atthe first position is executed, that the fourth transaction resource canbe executed successfully, and determines, according to the state of thesecond to-be-operated resource after the fourth transaction resource isexecuted, that a transaction resource at a second position in the secondtransaction resource queue can also be executed successfully (the secondposition is a next position adjacent to the position for inserting thefourth transaction resource in the second transaction resource queue),the second managed object device determines that the fourth transactionresource is created successfully, and sends the response indicative ofsuccessful creation of the fourth transaction resource of the secondtransaction to the application server, where a state of the fourthtransaction resource carried in the response is the semi-reserved state,and the response carries the identifier of the fourth transactionresource.

Optionally, after the fourth transaction resource is createdsuccessfully, and when the fourth execution time arrives, the secondmanaged object device executes the fourth to-be-executed operationincluded in the fourth transaction resource, deletes the executed fourthtransaction resource from the queue, switches the next transactionresource (namely, the transaction resource at the second position) fromthe semi-reserved state to the reserved state, and notifies theapplication server that the transaction resource at the second positionhas been switched to the reserved state.

As described above, in the case k, the state of the secondto-be-operated resource may be the state of the second to-be-operatedresource after the transaction resource at the first position isexecuted, or may be the state of the second to-be-operated resourceafter the fourth transaction resource is executed. Content of the stateof the second to-be-operated resource is determined according todifferent cases.

l. If it is determined, according to the fourth execution time, that atransaction resource in the second transaction resource queue existsbefore the position for inserting the fourth transaction resource in thesecond transaction resource queue, and that no transaction resource inthe second transaction resource queue exists after the insertingposition, when the second managed object device determines, according tothe state of the second to-be-operated resource after the transactionresource at the first position is executed, that the fourth transactionresource can be executed successfully, the second managed object devicedetermines that the fourth transaction resource is created successfully,and sends the response indicative of successful creation of the fourthtransaction resource of the second transaction to the applicationserver, where the state of the fourth transaction resource carried inthe response is the semi-reserved state, and the response carries theidentifier of the fourth transaction resource.

As described above, in the case l, the state of the secondto-be-operated resource may be the state of the second to-be-operatedresource after the transaction resource at the first position isexecuted.

D. When at least two transaction resources included in the secondtransaction resource queue are in the reserved state, the second managedobject device determines, according to the fourth execution time and thestate of the second to-be-operated resource, that the fourth transactionresource meets the preset resource creation condition, and creates thefourth transaction resource. Specifically, the following three cases m,n, and p may be included. It should be noted that, for details about thepreset resource creation condition, refer to the determining conditionsdescribed in m, n, and p.

m. If the second managed object device determines, according to thestate of the second to-be-operated resource after the fourth transactionresource is executed, that any other transaction resource in thereserved state after the position for inserting the fourth transactionresource in the second transaction resource queue can be executedsuccessfully, and the second managed object device determines that noother transaction resource in the second transaction resource queueexists before the inserting position, the second managed object devicedetermines that the fourth transaction resource is created successfully,and sends the response indicative of successful creation of the fourthtransaction resource of the second transaction to the applicationserver, where the state of the fourth transaction resource carried inthe response is the reserved state, and the response carries theidentifier of the fourth transaction resource.

As described above, in the case m, the state of the secondto-be-operated resource may be the state of the second to-be-operatedresource after the fourth transaction resource is executed.

n. If the second managed object device determines, according to thestate of the second to-be-operated resource after the fourth transactionresource is executed, that any other transaction resource in thereserved state in the second transaction resource queue after theposition for inserting the fourth transaction resource in the secondtransaction resource queue can be executed successfully, and the secondmanaged object device determines that another transaction resource inthe second transaction resource queue exists before the insertingposition, the second managed object device further determines, accordingto the state of the second to-be-operated resource after any transactionresource in the other transaction resources existing before theinserting position in the second transaction resource queue is executed,whether the fourth transaction resource can be executed successfully; ifyes, the second managed object device determines that the fourthtransaction resource is created successfully, and sends the responseindicative of successful creation of the fourth transaction resource ofthe second transaction to the application server, where the state of thefourth transaction resource carried in the response is the reservedstate, and the response carries the identifier of the fourth transactionresource.

As described above, in the case n, the state of the secondto-be-operated resource may be the state of the second to-be-operatedresource after the fourth transaction resource is executed, or may bethe state of the second to-be-operated resource after any transactionresource in the other transaction resources existing before the positionfor inserting the fourth transaction resource in the second transactionresource queue is executed. Content of the state of the secondto-be-operated resource is determined according to different cases.

p. If the second managed object device determines, according to thestate of the second to-be-operated resource after the fourth transactionresource is executed, that any other transaction resource in thereserved state in the second transaction resource queue after theposition for inserting the fourth transaction resource in the secondtransaction resource queue can be executed successfully, and the secondmanaged object device determines that another transaction resource inthe second transaction resource queue exists before the insertingposition, the second managed object device further determines, accordingto the state of the second to-be-operated resource after any transactionresource in the transaction resources existing before the insertingposition in the second transaction resource queue is executed, whetherthe fourth transaction resource can be executed successfully; if not(that is, the second managed object device determines, according to thestatus of the second to-be-operated resource after any transactionresource in the transaction resources existing before the insertingposition in the second transaction resource queue is executed, that thefourth transaction resource cannot be executed successfully), the secondmanaged object device further determines, according to the state of thesecond to-be-operated resource after the transaction resource at thefirst position is executed, whether the fourth transaction resource canbe executed successfully. If the second managed object devicedetermines, according to the state of the second to-be-operated resourceafter the transaction resource at the first position is executed, thatthe fourth transaction resource can be executed successfully, the secondmanaged object device determines that the fourth transaction resource iscreated successfully, and sends the response indicative of successfulcreation of the fourth transaction resource of the second transaction tothe application server, where the state of the fourth transactionresource carried in the response is the semi-reserved state, and theresponse carries the identifier of the fourth transaction resource.

As described above, in the case p, the state of the secondto-be-operated resource may be the state of the second to-be-operatedresource after the fourth transaction resource is executed, or may bethe state of the second to-be-operated resource after any transactionresource in the other transaction resources existing before the positionfor inserting the fourth transaction resource in the second transactionresource queue is executed, or may be the state of the secondto-be-operated resource after the transaction resource at the firstposition is executed. Content of the state of the second to-be-operatedresource is determined according to different cases.

In summary, all the foregoing five cases k, l, m, n, and p are cases inwhich the second managed object device determines, according to thefourth execution time and the state of the second to-be-operatedresource, that the fourth transaction resource meets the preset resourcecreation condition.

Based on the foregoing embodiment shown in FIG. 3, in a fourth possibleimplementation manner of this embodiment of the present invention, thisembodiment relates to a specific process in which when the processingrequest received by the second managed object device for the fourthtransaction resource of the second transaction is an update request thatcarries the identifier of the fourth transaction resource and theupdated third execution time, the second managed object device processesthe fourth transaction resource according to the update request. theforegoing S206 specifically includes: the second managed object devicesuccessfully updates the fourth transaction resource according to theupdated third execution time, and after the update succeeds, returns anupdate success response message to the application server; or fails toupdate the fourth transaction resource according to the updated thirdexecution time, and returns an update failure response message to theapplication server.

Specifically, after receiving the update request, the second managedobject device processes the fourth transaction resource successfullycreated by the second managed object device. The following two cases qand s may be included.

q. When the second managed object device determines that no secondtransaction resource queue exists on the second managed object device,that is, the second to-be-operated resource on the second managed objectdevice is currently not associated with a transaction resource ofanother transaction, but is associated with the fourth transactionresource only, the second managed object device determines whether theupdated third execution time does not comply with content of theforegoing (4), that is, the second managed object device determineswhether the updated third execution time falls within a sleep period ofthe second managed object device; if the updated third execution time isstill a working time of the second managed object device, the secondmanaged object device directly updates the fourth execution time of thesuccessfully created fourth transaction resource to the updated thirdexecution time, and sends the update success response message to theapplication server. If the updated third execution time is still a sleeptime of the second managed object device, the second managed objectdevice determines that the fourth transaction resource fails to beupdated, and sends the update failure response message to theapplication server.

r. When the second managed object device determines that the secondtransaction resource queue exists on the second managed object device,the second managed object device deletes, after receiving the updaterequest that carries the updated third execution time, the previouslysuccessfully created fourth transaction resource from the secondtransaction resource queue, and then uses the updated third executiontime as an execution time of a new fourth transaction resource; thesecond managed object device determines, according to the execution timeof the new fourth transaction resource and the state of thecorresponding second to-be-operated resource, that the new fourthtransaction resource meets the preset resource creation condition,creates the new fourth transaction resource according to the updatedthird execution time, and sends the update success response to theapplication server. That is, when the second managed object devicedetermines that the second transaction resource queue exists on thesecond managed object device, an operation performed by the secondmanaged object device after the update request is received is actuallyan operation of creating a new transaction resource again. For aspecific execution process, refer to the specific solutions described inthe foregoing a to r.

If the second managed object device successfully updates the fourthexecution time of the fourth transaction resource to the updated thirdexecution time according to the update request, and the first managedobject device successfully creates a new third transaction resourceaccording to the updated third execution time carried in the new thirdtransaction resource creation request (in addition, states of thetransaction resources carried in the responses that are sent by thefirst managed object device and the second managed object device to theapplication server about successful creation of the transactionresources of the second transaction are both the reserved state), andbefore the updated third execution time arrives, the application serverdoes not send any processing request, when the updated third executiontime arrives, the first managed object device and the second managedobject device simultaneously execute the operations to be executed bythe devices.

Based on the foregoing embodiment shown in FIG. 3, in a fifth possibleimplementation manner of this embodiment of the present invention, thisembodiment relates to a specific process in which when the processingrequest received by the second managed object device for the fourthtransaction resource of the second transaction is a deletion requestthat carries the identifier of the fourth transaction resource, thesecond managed object device processes the fourth transaction resourceaccording to the deletion request. As shown in FIG. 6, the foregoingS206 specifically includes:

S501. The second managed object device deletes the fourth transactionresource on the second managed object device according to the identifierof the fourth transaction resource.

S502. The second managed object device sends a deletion response to theapplication server.

Specifically, the following two cases s and t may be included.

s. When one transaction resource in the second transaction resourcequeue is in the reserved state, after the second managed object devicedeletes the fourth transaction resource, the second managed objectdevice executes a determining operation and obtains a determiningresult. The determining operation includes: the second managed objectdevice determines, according to the state of the second to-be-operatedresource after the transaction resource at the first position in thesecond transaction resource queue is executed, whether the transactionresource at the second position can be executed successfully (that is,the second managed object device determines, according to the state ofthe second to-be-operated resource after the transaction resource at thefirst position in the second transaction resource queue is executed,whether the transaction resource at the second position can enter thereserved state); the first position is a previous position adjacent tothe position for inserting the fourth transaction resource in the secondtransaction resource queue, and the second position is a next positionadjacent to the position for inserting the fourth transaction resourcein the second transaction resource queue.

After the second managed object device deletes the fourth transactionresource, if the second managed object device determines, according tothe state of the second to-be-operated resource after the transactionresource at the first position in the second transaction resource queueis executed, that the transaction resource at the second position isexecuted successfully, the second managed object device sends a firstdeletion response to the application server, updates the state of thetransaction resource at the second position to the reserved state afterthe transaction resource at the first position is executed, and notifiesthe application server that the transaction resource at the secondposition is already in the reserved state.

After the second managed object device deletes the fourth transactionresource, if the second managed object device determines, according tothe state of the second to-be-operated resource after the transactionresource at the first position in the second transaction resource queueis executed, that the transaction resource at the second position failsto be executed, the second managed object device deletes the transactionresource at the second position, and notifies the application serverthat the transaction resource at the second position has been deleted.The second managed object device further determines whether the deletedtransaction resource at the second position is a last transactionresource in the second transaction resource queue. If it is determinedthat the transaction resource at the second position is not the lasttransaction resource in the second transaction resource queue, thesecond managed object device uses a position next to the second positionas a new second position, and executes the foregoing determiningoperation on a transaction resource at the new second position. If it isdetermined that the transaction resource at the second position is thelast transaction resource in the second transaction resource queue, thetransaction resource deletion procedure is terminated.

Herein a simple example may be used for description. It is assumed thatthe second transaction resource queue includes four transactionresources, namely, T1, T2, T3, and T4. The fourth transaction resourceis inserted between T1 and T2, and it is assumed that the fourthtransaction resource is T5. T1 is in the reserved state, but T2, T3, andT4 are at the semi-reserved state, as shown in Table 1.

TABLE 1 Second transaction resource queue T1 T5 T2 T3 T4 Reserved Semi-Semi- Semi- Semi- reserved reserved reserved reserved

After the second managed object device deletes T5 from the secondtransaction resource queue, the second managed object device needs todetermine, according to the state of the second to-be-operated resourceafter the transaction resource at the first position in the secondtransaction resource queue is executed, whether the transaction resourceat the second position can be switched to the reserved state, that is,the second managed object device needs to determine, according to thestate of the second to-be-operated resource after T1 previous to T5 isexecuted, whether T2 can be switched to the reserved state. If yes, thesecond managed object device sends a first deletion response to theapplication server, updates the state of T2 to the reserved state afterT1 is executed, and notifies the application server that T2 is alreadyin the reserved state. If not, the second managed object device alsoneeds to delete T2, and notify the application server that T2 has beendeleted. Further, the second managed object device also needs todetermine whether the deleted T2 is a last transaction resource in thesecond transaction resource queue. If it is determined that T2 is notthe last transaction resource in the second transaction resource queue,the second managed object device continues to determine, according tothe state of the second to-be-operated resource after T1 is executed (inthis case, T5 and T2 have been deleted), whether T3 can be switched tothe reserved state; if yes, the second managed object device sends afirst deletion response to the application server, updates the state ofT3 to the reserved state after T1 is executed, and notifies theapplication server that T3 is already in the reserved state; if not, thesecond managed object device also needs to delete T3, and notify theapplication server that T3 has been deleted. Further, the second managedobject device also needs to determine whether the deleted T3 is the lasttransaction resource in the second transaction resource, and so on,until it is determined that the deleted transaction resource is the lasttransaction resource in the second transaction resource queue, and thenthe deletion procedure is terminated.

t. If at least two transaction resources in the second transactionresource queue are in the reserved state, after the second managedobject device deletes the fourth transaction resource, the secondmanaged object device determines whether a transaction resource in thesemi-reserved state in the second transaction resource queue meets apreset deletion condition.

After the second managed object device deletes the fourth transactionresource, if the second managed object device determines, according tothe state of the second to-be-operated resource after the fourthtransaction resource is deleted, that the transaction resource in thesemi-reserved state in the second transaction resource queue meets thepreset deletion condition, that is, after the fourth transactionresource is deleted, the second managed object device determines,according to the status of the second to-be-operated resource after thefourth transaction resource is deleted (that is, after the fourthtransaction resource is deleted, the second managed object devicedetermines, according to the status of the second to-be-operatedresource after any transaction resource previous to the transactionresource in the semi-reserved state is executed), that the transactionresource in the semi-reserved state in the second transaction resourcequeue cannot be executed successfully, the second managed object devicedeletes the transaction resource in the semi-reserved state, and sends asecond deletion response to the application server, so as to notify theapplication server that the transaction resource has been deleted.

Herein a simple example may be used for description. It is assumed thatthe second transaction resource queue includes four transactionresources, namely, T1, T2, T3, and T4. The foregoing T1, T2, and T4 areall in the reserved state, T3 is in the semi-reserved state, and it isassumed that T2 is the fourth transaction resource, as shown in Table 2.

TABLE 2 T1 T2 T3 T4 Reserved Reserved Semi-reserved Reserved

After the fourth transaction resource T2 is deleted, the second managedobject device determines whether T3 can be switched to the reservedstate. Whether T3 can be executed successfully depends only on the stateof the second to-be-operated resource after T2 is executed (T3 is in thesemi-reserved state because when T3 is created, it is determined thatany transaction resource in the reserved state after T3 in the queue canbe executed successfully based on the state of the second to-be-operatedresource after T3 is executed, and it is also determined that T1 and T2exist before T3, and that T3 can be committed based on the state of thesecond to-be-operated resource after T2 is executed, but T3 cannot becommitted based on the state of the second to-be-operated resource afterT1 is executed; therefore, T3 is created, and it is determined that thestate of T3 is the semi-reserved state). Therefore, successful executionof T3 depends only on the state of the second to-be-operated resourceafter T2 is executed, and T3 also cannot be executed successfully afterT2 is deleted. Therefore, the second managed object device also needs todelete T3, and send a second deletion response to the applicationserver, so as to notify the application server that the transactionresource has been deleted.

After the second managed object device deletes the fourth transactionresource, if the second managed object device determines, according tothe state of the second to-be-operated resource after the fourthtransaction resource is deleted, that the transaction resource in thesemi-reserved state in the second transaction resource queue does notmeet the preset deletion condition, that is, after the fourthtransaction resource is deleted, based on the state of the secondto-be-operated resource after the fourth transaction resource is deleted(that is, after the fourth transaction resource is deleted, based on thestate of the second to-be-operated resource after any transactionresource previous to that in the semi-reserved state is executed), thetransaction resource in the semi-reserved state can be executedsuccessfully, the second managed object device updates the transactionresource in the semi-reserved state to the reserved state.

Herein a simple example is also used for description. It is assumed thatthe second transaction resource queue includes four transactionresources, namely, T1, T2, T3, and T4. The foregoing T1, T2, and T4 areall in the reserved state, T3 is in the semi-reserved state, and it isassumed that T1 is the fourth transaction resource, as shown in Table 3.

TABLE 3 T1 T2 T3 T4 Reserved Reserved Semi-reserved Reserved

After the fourth transaction resource T1 is deleted, the second managedobject device determines whether T3 can be switched to the reservedstate. Whether T3 can be switched to the reserved state depends only onthe state of the second to-be-operated resource after T2 is executed.Therefore, after T1 is deleted, the semi-reserved state of T3 is notaffected, that is, the second managed object device determines,according to the status of the second to-be-operated resource after T2is executed, that T3 can be executed successfully. Therefore, the secondmanaged object device further determines, according to the state of thesecond to-be-operated resource after any transaction resource previousto T3 is executed, that T3 can be executed successfully (in thisexample, only T2 remains after T1 is deleted, and therefore, for T3,refer to only the state of the second to-be-operated resource after T2is executed). In this case, after T2 is executed, the second managedobject device updates T3 to the reserved state.

It should be noted that, in the fourth possible implementation mannerand the fifth possible implementation manner of the embodiment shown inFIG. 3, if the second managed object device executes a deletion requestor an update request, execution of a transaction resource in thereserved state is affected. This means that if the deletion request orthe update request is executed, an original executable state of thetransaction resource is destructed, and further, atomicity of thetransaction is destructed. Therefore, the second managed object devicerejects the deletion request or the update request in this case.

To better describe the technical solution of this application, thefollowing uses two examples of intelligent irrigation for specificdescription. An example 1 mainly relates to a scenario in which a secondtransaction resource queue includes one transaction resource in areserved state. An example 2 mainly relates to a scenario in which asecond transaction resource queue includes at least two transactionresources in a reserved state:

Example 1: This scenario relates to a process of processing concurrenttransactions, and a second transaction resource queue on a managedobject device includes one transaction resource in a reserved state. Theapplication server has six transactions in total, which are respectivelya transaction 1, a transaction 2, a transaction 3, a transaction 4, atransaction 5, and a transaction 6. The transactions relate to threemanaged object devices, which are respectively a first managed objectdevice A (a valve 1), a second managed object device (a valve 2), and afirst managed object device B (a valve 3). For the transaction 1, theapplication server sends a fourth transaction resource creation requestT1 to the valve 2, and sends a third transaction resource creationrequest R1 to the valve 1 and valve 3; for the transaction 2, theapplication server sends a fourth transaction resource creation requestT2 to the valve 2, and sends a third transaction resource creationrequest R2 to the valve 1 and the valve 3; for the transaction 3, theapplication server sends a fourth transaction resource creation requestT3 to the valve 2, and sends a third transaction resource creationrequest R4 to the valve 1 and the valve 3; for the transaction 4, theapplication server sends a fourth transaction resource creation requestT4 to the valve 2, and sends a third transaction resource creationrequest R4 to the valve 1 and the valve 3; for the transaction 5, theapplication server sends a fourth transaction resource creation requestT5 to the valve 2, and sends a third transaction resource creationrequest R5 to the valve 1 and the valve 3; and for the transaction 6,the application server sends a fourth transaction resource creationrequest T6 to the valve 2, and sends a third transaction resourcecreation request R6 to the valve 1 and the valve 3. The followingdescribes only an operation on the second managed object device (namely,the valve 2). For operations on the valve 1 and the valve 3, refer tothe operation on the valve 2.

It should be noted that, the application server sends the T1 request,the T2 request, the T3 request, the T4 request, the T5 request, and theT6 request to the valve 2 in sequence in an order of transactions.

A fourth transaction resource to be created according to the T1 requestis t1, a fourth transaction resource to be created according to the T2request is t2, a fourth transaction resource to be created according tothe T3 request is t3, a fourth transaction resource to be createdaccording to the T4 request is t4, a fourth transaction resource to becreated according to the T5 request is t5, and a fourth transactionresource to be created according to the T6 request is t6. The followingdescribes only an operation on the second managed object device (namely,the valve 2). For operations on the valve 1 and the valve 3, refer tothe operation on the valve 2.

For the transaction 1, the application server sends the T1 request tothe valve 2, requesting to adjust the valve 2 to 30% at 12:00. Afterreceiving the T1 request, the valve 2 checks that no second transactionresource exists on the valve 2 in this case. The valve 2 furtherdetermines, based on a state of a second to-be-operated resource in thiscase, that a fourth transaction resource t1 can be created successfully,and therefore creates t1, where t1 is in the reserved state. The valve 2returns a response indicative of successful creation of the fourthtransaction resource to the application server. In this case, the secondtransaction resource queue for the second to-be-operated resource on thevalve 2 is shown in Table 4. After t1 is created successfully, t1becomes a transaction resource in the second transaction resource queue.

TABLE 4 t1 30% 12:00 Reserved

For the transaction 2, the application server sends the T2 request tothe valve 2, requesting to adjust the valve 2 to 40% at 12:05. Afterreceiving the T2 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1. The valve 2 determines, according to the execution time 12:05required by the T2 request and the execution time 12:00 of t1 in thesecond transaction resource queue, that a fourth transaction resource t2to be created according to the T2 request should be created in a lastposition in the second transaction resource queue. The valve 2 furtherconfirms and determines, based on the state of the second to-be-operatedresource after t1 is executed, that t2 may be switched to the reservedstate. Therefore, the valve 2 successfully creates t2, and a currentstate of t2 is a semi-reserved state. The valve 2 returns a responseindicative of successful creation of the fourth transaction resource tothe application server. In this case, the second transaction resourcequeue for the second to-be-operated resource on the valve 2 is shown inTable 5. In addition, after t2 is created successfully, t2 becomes atransaction resource in the second transaction resource queue.

TABLE 5 t1 t2 30% 40% 12:00 12:05 Reserved Semi-reserved

For the transaction 3, the application server sends the T3 request tothe valve 2, requesting to adjust the valve 2 to 20% at 12:03. Afterreceiving the T3 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1 and t2. The valve 2 determines, according to the execution time 12:03required by the T3 request, the execution time 12:00 of t1 in the secondtransaction resource queue, and the execution time 12:05 of t2, that afourth transaction resource t3 to be created according to the T3 requestshould be created between t1 and t2. The valve 2 further confirms anddetermines, based on the state of the second to-be-operated resourceafter t1 is executed (in this case, the state of the secondto-be-operated resource is that an opening degree of the valve 2 is30%), that t3 may be switched to the reserved state (that is, the valve2 determines that the valve 2 may be adjusted from 30% to 20%, where anadjustment range is within a preset threshold range, assuming that thepreset threshold is 60%), and determines, based on the state of thesecond to-be-operated resource after t3 is executed (in this case, thestate of the second to-be-operated resource is that an opening degree ofthe valve 2 is 20%), that t2 may also be switched to the reserved state(that is, the valve 2 determines that the valve 2 may be adjusted from20% to 40%, where an adjustment range is within the preset thresholdrange). Therefore, the valve 2 creates t3 successfully, and a currentstate of t3 is a semi-reserved state. The valve 2 returns a responseindicative of successful creation of the fourth transaction resource tothe application server. In this case, the second transaction resourcequeue for the second to-be-operated resource on the valve 2 is shown inTable 6. In addition, after t3 is created successfully, t3 becomes atransaction resource in the second transaction resource queue.

TABLE 6 t1 t3 t2 30% 20% 40% 12:00 12:03 12:05 Reserved Semi-reservedSemi-reserved

For the transaction 4, the application server sends the T4 request tothe valve 2, requesting to adjust the valve 2 to 20% at 11:55. Afterreceiving the T4 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1, t2, and t3. The valve 2 determines, according to the execution time11:55 required by the T4 request and the execution time 12:00 of t1 inthe queue, that a fourth transaction resource t4 to be created accordingto the T4 request should be created before t1, namely, a first positionin the second transaction resource queue. Because t1 is already in thereserved state, if another transaction resource is created before t1,the reserved transaction resource t1 cannot be executed (an M2M systemdoes not allow this possibility to exist). However, the valve 2 checksthat if an execution time of t4 is set to be later than 12:05, that is,if t4 is created after t2, based on the state of the secondto-be-operated resource after t2 is executed (the state of the secondto-be-operated resource after t2 is executed is 40%), t4 can be executedsuccessfully (that is, the valve 2 determines that the valve 2 may beadjusted from 40% to 20%, where an adjustment range is within the presetthreshold range). Therefore, the valve 2 returns a second failureresponse to the application server, but the response carries anappropriate execution time 12:10. In this case, the second transactionresource queue for the second to-be-operated resource on the valve 2 isstill shown in Table 6.

For the transaction 5, the application server sends the T5 request tothe valve 2, requesting to adjust the valve 2 to 80% at 12:02. Afterreceiving the T5 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1, t2, and t3. The valve 2 determines, according to the execution time12:02 required by the T5 request, the execution time 12:00 of t1 in thequeue, and the execution time 12:03 of t3, that t5 should be createdbetween t1 and t2 in the transaction resource queue. However, if t5 isexecuted successfully, the opening degree of the valve is 80% (that is,in this case, the state of the second to-be-operated resource on thevalve 2 is 80%), but t3 requests to adjust the opening degree of thevalve 2 to 20% at this time (that is, adjust the valve 2 from 80% to20%), for self-protection, the valve 2 does not allow a growth rangebetween two adjustments to be greater than or equal to a presetthreshold (assuming 60%), because if the growth range of the valve 2 isequal to 60%, great impact is caused to subsequent flexible pipes andinterfaces, resulting in a phenomenon of water leakage or jointloosening. Therefore, the valve 2 determines that after t5 is executed,t3 in the semi-reserved state is affected and cannot enter the reservedstate. Therefore, the valve 2 returns a second failure response to theapplication server. However, likewise, the valve 2 checks that, if t5 iscreated after t2, t5 can be created successfully. Therefore, the secondfailure response carries an appropriate execution time 12:10. In thiscase, the second transaction resource queue for the secondto-be-operated resource on the valve 2 is still shown in Table 6.

For the transaction 6, the application server sends the T6 request tothe valve 2, requesting to adjust the valve 2 to 100% at 12:08. Afterreceiving the T6 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1, t2, and t3. The valve 2 determines, according to the execution time12:08 required by the T6 request and the execution time 12:05 of t2 inthe queue, that t6 should be created after t2 in the second transactionresource queue, namely, the last position in the second transactionresource queue. However, after t2 is executed successfully, the openingdegree of the valve 2 is 40% (that is, in this case, the state of thesecond to-be-operated resource on the valve 2 is 40%), but t6 requeststo adjust the opening degree of the valve 2 to 100% at this time.Therefore, a growth range of the valve is equal to the preset threshold(assuming 60%). Therefore, the valve 2 determines that after t2 isexecuted, t6 cannot enter the reserved state, and at the same time, thevalve 2 checks that a 100% adjustment of t6 is not appropriate anywherein the second transaction resource queue, and therefore returns a firstfailure response.

For deletion of a transaction resource in the transaction 1 (onetransaction includes multiple transaction resources, the multipletransaction resources are created by different managed object devicesrespectively, and t1, t2, and t3 in the foregoing Table 6 aretransaction resources that belong to different transactions), in thetransaction 1, the application server sends a fourth transactionresource creation request to the valve 2, and a fourth transactionresource is created successfully on the valve 2, where the fourthtransaction resource is assumed to be the foregoing t1. In addition, theapplication server receives a response sent by the valve 1 aboutunsuccessful creation of a third transaction resource. This indicatesthat the third transaction resource of the transaction 1 cannot becreated successfully on the valve 1. Therefore, the application serverneeds to delete t1 that has been created successfully on the valve 2.Therefore, the application server sends a deletion request that carriesan identifier of t1 to the valve 2, so that the valve 2 receives, beforethe execution time of t1 arrives, the deletion request sent by theapplication server, where the deletion request is used to delete t1 inthe second transaction resource queue. The valve 2 determines, accordingto the current second transaction resource queue, that deletion of t1does not affect the semi-reserved state of t3. Because after t1 isdeleted, the valve 2 is directly opened to 20% from full closing.Therefore, t3 can enter the reserved state. After t1 is executed, thevalve 2 updates the state of t2 from the semi-reserved state to thereserved state, and notifies the application server that t2 has enteredthe reserved state.

For execution of a transaction resource in the transaction 2, the valve2 confirms that no deletion request for deleting t2 of the transaction 2or no update request sent by the application server is received. After12:05 arrives, the valve 2 executes a to-be-operated operation in t2,that is, adjusting the opening degree of the valve to 40%. Then, thevalve removes t2 from the second transaction resource queue. In thiscase, if another transaction resource Tx exists after t2 in the secondtransaction resource queue, the valve 2 switches the state of Tx fromthe semi-reserved state to the reserved state, and sends a notificationto the application server, notifying that Tx has entered the reservedstate.

The example 1 is intended for a scenario in which the second transactionresource queue includes one transaction resource in the reserved state,and describes a process of processing concurrent transactions by theapplication server and the second managed object device, and a technicalsolution to maintaining the second transaction resource queue of thesecond managed object device during the processing.

Example 2: This scenario relates to a process of processing concurrenttransactions, and a second transaction resource queue on a managedobject device includes at least two transaction resources in a reservedstate. The application server has six transactions in total, which arerespectively a transaction 1, a transaction 2, a transaction 3, atransaction 4, a transaction 5, and a transaction 6. The transactionsrelate to three managed object devices, which are respectively a firstmanaged object device A (a valve 1), a second managed object device (avalve 2), and a first managed object device B (a valve 3). For thetransaction i, the application server sends a fourth transactionresource creation request T1 to the valve 2, and sends a thirdtransaction resource creation request R1 to the valve 1 and valve 3; forthe transaction 2, the application server sends a fourth transactionresource creation request T2 to the valve 2, and sends a thirdtransaction resource creation request R2 to the valve 1 and the valve 3;for the transaction 3, the application server sends a fourth transactionresource creation request T3 to the valve 2, and sends a thirdtransaction resource creation request R4 to the valve 1 and the valve 3;for the transaction 4, the application server sends a fourth transactionresource creation request T4 to the valve 2, and sends a thirdtransaction resource creation request R4 to the valve 1 and the valve 3;for the transaction 5, the application server sends a fourth transactionresource creation request T5 to the valve 2, and sends a thirdtransaction resource creation request R5 to the valve 1 and the valve 3;and for the transaction 6, the application server sends a fourthtransaction resource creation request T6 to the valve 2, and sends athird transaction resource creation request R6 to the valve 1 and thevalve 3. The following describes only an operation on the second managedobject device (namely, the valve 2). For operations on the valve 1 andthe valve 3, refer to the operation on the valve 1.

It should be noted that, the application server sends the T1 request,the T2 request, the T3 request, the T4 request, the T5 request, and theT6 request to the valve 2 in sequence in an order of transactions. It isassumed that the application server sends the T1 request, the T2request, the T3 request, the T4 request, the T5 request, and the T6request to the valve 2 in sequence.

A fourth transaction resource to be created according to the T1 requestis t1, a fourth transaction resource to be created according to the T2request is t2, a fourth transaction resource to be created according tothe T3 request is t3, a fourth transaction resource to be createdaccording to the T4 request is t4, a fourth transaction resource to becreated according to the T5 request is t5, and a fourth transactionresource to be created according to the T6 request is t6. The followingdescribes only an operation on the second managed object device (namely,the valve 2). For operations on the valve 1 and the valve 3, refer tothe operation on the valve 2. It should be noted that, an initial stateof the valve 2 is 25%.

For the transaction 1, the application server sends the T1 request tothe valve 2, requesting to adjust the valve 2 to 40% at 12:00. Afterreceiving the T1 request, the valve 2 checks that no second transactionresource for a second to-be-operated resource exists on the valve 2 inthis case. The valve 2 further checks and determines, based on a stateof the second to-be-operated resource in this case, that a fourthtransaction resource t1 can be created successfully, and thereforecreates t1, where t1 is in the reserved state. The valve 2 returns aresponse indicative of successful creation of the fourth transactionresource to the application server. In this case, the second transactionresource queue for the second to-be-operated resource on the valve 2 isshown in Table 7. After t1 is created successfully, t1 becomes atransaction resource in the second transaction resource queue.

TABLE 7 t1 40% 12:00 Reserved

For the transaction 2, the application server sends the T2 request tothe valve 2, requesting to adjust the valve 2 to 80% at 12:05. Afterreceiving the T2 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2 in this case, and that the second transaction resourcequeue includes t1. The valve 2 determines, according to the executiontime 12:05 required by the T2 request and the execution time 12:00 of t1in the second transaction resource queue, that t2 to be createdaccording to the T2 request should be created in a last position in thesecond transaction resource queue. Therefore, the valve 2 confirms thatthe fourth transaction resource t2 to be created does not affect thereserved state of another transaction resource after the position of thetransaction resource t2 to be created in the second transaction resourcequeue. In the second transaction resource queue shown in the foregoingTable 7, t1 further exists before t2. The valve 2 confirms that, whetherbased on the state of the second to-be-operated resource after t1 isexecuted or based on a current state of the second to-be-operatedresource after t1 is deleted (namely, the initial state 25% of the valve2), t2 can enter the reserved state. Therefore, the valve 2 creates t2successfully, and a current state of t2 is the reserved state. The valve2 returns a response indicative of successful creation of the fourthtransaction resource to the application server. In this case, the secondtransaction resource queue for the second to-be-operated resource on thevalve 2 is shown in Table 8. After t2 is created successfully, t2becomes a transaction resource in the second transaction resource queue.

TABLE 8 t1 t2 40% 80% 12:00 12:05 Reserved Reserved

For the transaction 3, the application server sends the T3 request tothe valve 2, requesting to adjust the valve 2 to 10% at 12:03. Afterreceiving the T3 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1 and t2. The valve 2 determines, according to the execution time 12:03required by the T3 request, the execution time 12:00 of t1 in the queue,and the execution time 12:05 of t2, that t3 is located between t1 andt2. In addition, successful creation of t3 may cause an adjustment rangeof t2 of the valve 2 to increase from 10% (10% of t3) to 80% (80% of t2)directly. This exceeds a limit that one adjustment of the valve 2 shouldnot exceed 60%. Therefore, the reserved state of the t2 is affected.Therefore, t3 fails to be created. If t3 is created before t1, t3 can becreated successfully. Therefore, a first failure response is returned,where the response includes an appropriate execution time 11:59. In thiscase, the second transaction resource queue for the secondto-be-operated resource on the valve 2 is still shown in Table 8.

For the transaction 4, the application server sends the T4 request tothe valve 2, requesting to adjust the valve 2 to 30% at 11:55. Afterreceiving the T4 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1 and t2. According to the execution time 11:55 required by the T4request and the execution time 12:00 of t1 in the queue, the valve 2determines that t4 should be created before t1 in the second transactionresource queue. Because t1 and t2 are already in the reserved state, thevalve 2 determines that, if t4 is created successfully, valve opening to30% (that is, the state of the second to-be-operated resource after t4is executed is 30%) does not affect normal execution of t1 and t2, andthat no other transaction resource exists before t4 in the secondtransaction resource queue. Therefore, the valve 2 returns a responseindicative of successful creation of the fourth transaction resource tothe application server, where t4 is in the reserved state. In this case,the second transaction resource queue for the second to-be-operatedresource on the valve 2 is shown in Table 9. After t4 is createdsuccessfully, t4 becomes a transaction resource in the secondtransaction resource queue.

TABLE 9 t4 t1 t2 30% 40% 80% 11:55 12:00 12:05 Reserved ReservedReserved

For the transaction 5, the application server sends the T5 request tothe valve 2, requesting to adjust the valve 2 to 100% at 12:02. Afterreceiving the T5 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1, t2, and t4. The valve 2 determines, according to the execution time12:02 required by the T5 request, the execution time 12:00 of t1 in thequeue, and the execution time 12:05 of t2, that t5 should be createdbetween t1 and t2 in the second transaction resource queue. Successfulcreation of t5 does not affect the reserved state of t2. However, t4 andt1 also exist before t5. Whether based on the state of theto-be-operated resource after t4 is executed or based on that after t1is executed, t5 cannot be created successfully. For either 30% of t4 or40% of t1, the 100% adjustment exceeds the limit 60%. Therefore, t5fails to be created. However, the valve 2 checks that if t5 is createdafter t2, t5 can be created successfully. Therefore, a second failureresponse is returned, where the response includes an appropriateexecution time 12:10. In this case, the second transaction resourcequeue for the second to-be-operated resource on the valve 2 is stillshown in Table 9.

For the transaction 6, the application server sends the T6 request tothe valve 2, requesting to adjust the valve 2 to 90% at 12:02. Afterreceiving the T6 request, the valve 2 confirms that the secondtransaction resource queue for the second to-be-operated resource existson the valve 2, and that the second transaction resource queue includest1, t2, and t4. The valve 2 determines, according to the execution time12:02 required by the T6 request, the execution time 12:00 of t1 in thequeue, and the execution time 12:05 of t2, that t6 should be createdbetween t1 and t2 in the second transaction resource queue. Successfulcreation of t6 does not affect the reserved state of t2. However, t4 andt1 also exist before t6. Based on a result after t1 is executed, t6 canbe executed. However, based on a result after t4 is executed, t6 cannotbe created successfully. For 30% of t4, the 90% adjustment exceeds thelimit 60%. Therefore, although t6 is created successfully, t6 is in asemi-reserved state, and the valve 2 returns a response indicative ofsuccessful creation of the fourth transaction resource to theapplication server. In this case, the second transaction resource queuefor the second to-be-operated resource on the valve 2 is shown in Table10. After t6 is created successfully, t6 becomes a transaction resourcein the second transaction resource queue, and t6 is in the semi-reservedstate.

TABLE 10 t4 t1 t6 t2 30% 40% 90% 80% 11:55 12:00 12:02 12:05 ReservedReserved Semi-reserved Reserved

For execution of the transaction resource t4, when 11:55 arrives, thevalve 2 executes a to-be-executed operation in t4, that is, the valve 2is switched to 30% opening, and then t4 is deleted (that is, the stateof the second to-be-operated resource is 30% in this case). The currentsecond transaction resource queue is shown in the following Table 11.

TABLE 11 t1 t6 t2 40% 90% 80% 12:00 12:02 12:05 Reserved Semi-reservedReserved

For deletion of the transaction resource t1, in the transaction 1, theapplication server sends a fourth transaction resource creation requestT1 to the valve 2, and the valve 2 successfully creates t1 in the secondtransaction resource queue. In addition, the application server receivesa response indicative of unsuccessful creation of a third transactionresource from the valve 1, and this indicates that the third transactionresource of the transaction 1 cannot be created successfully on thevalve 1. Therefore, the application server needs to delete t1 that hasbeen created successfully on the valve 2. Therefore, the applicationserver sends a deletion request that carries an identifier of t1 to thevalve 2, so that the valve 2 receives, before the execution time of t1arrives, the deletion request sent by the application server, where thedeletion request is used to delete t1 in the second transaction resourcequeue. The valve 2 determines, according to the current secondtransaction resource queue (referring to Table 11), that only t6 aftert1 is in the semi-reserved state. The valve 2 determines whetherdeletion of t1 affects the semi-reserved state of t6. Because after t1is deleted, the valve 2 determines, according to the current status ofthe second to-be-operated resource (30% opening), that t6 cannot enterthe reserved state, the valve 2 deletes t6, and notifies the applicationserver that t6 has been deleted.

For deletion of the transaction resource t4, in the second transactionresource queue shown in the foregoing Table 10, assuming that before t4is executed, the valve 2 receives an update request requesting the valve2 to be directly opened to 40%. After receiving the update request, thevalve 2 is updated from the initial 25% state to 40%, where theadjustment range does not exceed a preset threshold, that is, thecurrent state of the second to-be-operated resource is 40%.

If before 11:55, another valve related to t4 fails to create a thirdtransaction resource that belongs to the transaction 4, t4 on the valve2 also needs to be deleted. The valve 2 receives a deletion request sentby the application server, where the deletion request carries anidentifier of t4 and is used to delete t4 in the second transactionresource queue. After the valve 2 deletes t4, only t6 after t4 is in thesemi-reserved state according to the current second transaction resourcequeue. The valve 2 determines whether deletion of t4 affects thesemi-reserved state of t6. After t4 is deleted, whether based on thecurrent state (40% opening) of the second to-be-operated resource orbased on the state (40% opening) after t1 is executed, t6 can enter thereserved state. Therefore, the valve 2 updates the state of t6 toreserved, and notifies the application server that t6 is already in thereserved state.

The example 2 is intended for a scenario in which the second transactionresource queue includes at least two transaction resources in thereserved state, and describes a process of processing concurrenttransactions by the application server and the second managed objectdevice, and a technical solution to maintaining the second transactionresource queue of the second managed object device during theprocessing.

FIG. 7 is a schematic flowchart of Embodiment 3 of a method forexecuting distributed transaction resources according to the presentinvention. This method is applied to an M2M system. The M2M systemincludes at least two managed object devices and an application server.A first managed object device is any one of the at least two managedobject devices, and the second managed object is any managed objectdevice except the first managed object device in the at least twomanaged object devices. As shown in FIG. 7, the method includes thefollowing steps.

S601. An application server sends a first transaction resource creationrequest for a first transaction to a first managed object device, wherethe first transaction resource creation request includes an identifierof a first to-be-operated resource, a first execution time, and a firstto-be-executed operation.

S602. The application server sends a second transaction resourcecreation request for the first transaction to a second managed objectdevice, where the second transaction resource creation request includesthe identifier of the first to-be-operated resource, a second executiontime, and a second to-be-executed operation, and the first executiontime and the second execution time are the same.

Specifically, the application server sends the first transactionresource creation request for the first transaction to the first managedobject device and the second transaction resource creation request forthe first transaction to the second managed object device separately,that is, both a first transaction resource and a second transactionresource belong to the first transaction of the application server. Thefirst transaction resource creation request includes the identifier ofthe first to-be-operated resource, the first execution time, and thefirst to-be-executed operation. The second transaction resource creationrequest includes the identifier of the second to-be-operated resource,the second execution time, and the second to-be-executed operation. Thefirst execution time and the second execution time are the same.Optionally, the first to-be-executed operation and the secondto-be-executed operation may be the same or may be different. Inaddition, the first to-be-executed operation or the secondto-be-executed operation may be reflected in a primitive form, or may bereflected in another manner.

It should be noted that, operations executed by the first managed deviceand the second managed object device are similar. Therefore, in all ofthe following technical solutions, the first managed object device isused as a described object. For the operation executed by the secondmanaged object device, refer to the operation executed by the firstmanaged object device. For the process of creating the secondtransaction resource by the second managed object device, refer to theprocess of creating the first transaction resource by the first managedobject device.

S603. The application server receives, within a preset time, a responsethat is sent by the second managed object device and that is indicativeof successful creation of a second transaction resource of the firsttransaction, and receives a response that is sent by the first managedobject device and that is indicative of successful creation of a firsttransaction resource of the first transaction.

Specifically, the first managed object device determines, according toinformation such as the first execution time and the firstto-be-executed operation that are carried in the first transactionresource creation request, whether the first transaction resource can becreated successfully. The first to-be-executed operation includes arequest for the first to-be-operated resource, and the request mayinclude information such as an initiator of the request, an identifierof a requested target resource, and specific content that is requested.

Optionally, the first managed object device may determine, according tothe information included in the first to-be-executed operation, whetherthe first transaction resource creation request meets a transactionresource creation condition. Specifically, the condition may includecontent of the following (1) to (4): (1) The first managed object devicechecks, according to “the identifier of the requested target resource”included in the first to-be-executed operation, whether the targetresource requested for the first to-be-executed operation is the firstto-be-operated resource. (2) The first managed object device checks,according to “the initiator of the request” included in the firstto-be-executed operation, whether the initiator (namely, the applicationserver) has enough rights to initiate the first transaction resourcecreation request. (3) The first managed object device checks, accordingto “the requested content” included in the first to-be-executedoperation, whether the requested content can be executed for the firstto-be-operated resource. (4) The first managed object device checks,according to the first execution time and arrangements of work and sleepperiods of the first managed object device, whether execution of thefirst to-be-executed operation carried in the first transaction resourcecreation request, at a time specified by the first execution time, canbe ensured.

If the foregoing four items are all checked successfully, it indicatesthat the first transaction resource creation request meets thetransaction resource creation condition, and the first managed objectdevice can successfully create the first transaction resource accordingto the first transaction resource creation request. Based on a featureof a RESTful architecture, the created first transaction resource mayinclude three attributes, namely, a current state of the firsttransaction resource, the first execution time, and the firstto-be-executed operation (correspondingly, the second transactionresource includes three attributes, namely, a state of the secondtransaction resource, the second execution time, and the secondto-be-executed operation).

Further, the first managed object device sends the response indicativeof successful creation of the first transaction resource of the firsttransaction to the application server, so as to notify the applicationserver that the first transaction resource is created successfully.Similar to the foregoing execution process of the first managed objectdevice, the second managed object device also determines that the secondtransaction resource is created successfully, and sends the responseindicative of successful creation of the second transaction resource ofthe first transaction to the application server, so as to notify theapplication server that the second transaction resource is createdsuccessfully. Regardless of whether the response is the responseindicative of successful creation of the first transaction resource orthe response indicative of successful creation of the second transactionresource, the response may carry the identifier of the respectivelycreated transaction resource, or may further carry the state of therespectively created transaction resource, where the state may be areserved state or a semi-reserved state.

It should be noted that, the application server needs to determinewhether transaction resource creation responses sent by the firstmanaged object device and the second managed object device are receivedwithin the preset time. Herein regardless of whether the transactionresource creation response is a success response or a failure response,as long as the application server fails to receive the transactionresource creation response within the preset time, the applicationserver considers that the transaction resource fails to be created.

If the application server receives, within the preset time, the responsethat is sent by the second managed object device and that is indicativeof successful creation of the second transaction resource, but fails toreceive any transaction resource creation response sent by the firstmanaged object device, the application server determines that the firsttransaction resource fails to be created, and sends a deletion requestto the second managed object device that has successfully created thesecond transaction resource, so as to delete the second transactionresource successfully created on the second managed object device andensure atomicity of the transaction. If the application server fails toreceive, within the preset time, any transaction resource creationresponse sent by the first managed object device and the second managedobject device, the application server terminates the creation procedure.

Further, in this embodiment of the present invention, because both thefirst managed object device and the second managed object device sendresponses about successful creation of transaction resources of thefirst transaction to the application server, the application serverdetermines, after determining that the response indicative of successfulcreation of the first transaction resource and the response indicativeof successful creation of the second transaction resource are receivedwithin the preset time, not to send a processing request to the firstmanaged object device and the second managed object device. Therefore,the first managed object device fails to receive, before the firstexecution time arrives (or the second managed object device fails toreceive, before the second execution time arrives), the processingrequest sent by the application server. Therefore, when the firstexecution time (second execution time) arrives, the first managed objectdevice and the second managed object can simultaneously execute theto-be-executed operations in the transaction resources respectivelycreated by the devices.

In the method for executing distributed transaction resources accordingto this embodiment of the present invention, transaction resourcecreation requests sent by an application server to multiple managedobject devices carry a same execution time, so that when it isdetermined that transaction resources are created successfully and theexecution time arrives, the multiple managed object devicessimultaneously execute the transaction resources created by the managedobject devices, thereby ensuring that the transaction resources areexecuted simultaneously. In addition, in this embodiment of the presentinvention, to ensure that the transaction resources are executedsimultaneously, the application server needs to send only onetransaction resource creation request to a managed object device.Therefore, signaling overheads of the application server are reduced.

Further, if the state of the second transaction resource carried in theresponse, sent by the second managed object device to the applicationserver after the second managed object device successfully creates thesecond transaction resource, about successful creation of the secondtransaction resource, is the semi-reserved state, after the foregoingS603, referring to FIG. 8, the method further includes:

S701. The application server subscribes to the second transactionresource, so that the second managed object device sends a notificationmessage to the application server when the state of the secondtransaction resource changes.

S702. The application server determines the state of the secondtransaction resource according to the notification message.

In this embodiment, the application server can monitor the state of thesecond transaction resource on the second managed object device at anytime, and trace a change at any time when the state of the secondtransaction resource changes. This ensures accuracy of the state whenthe transaction resource is executed.

FIG. 9 is a schematic flowchart of Embodiment 5 of a method forexecuting distributed transaction resources according to the presentinvention. Based on the foregoing embodiment shown in FIG. 7 or FIG. 8,the method used in this embodiment is a process in which the firstmanaged object device determines that a third transaction resource failsto be created, and sends a response indicative of unsuccessful creationof the third transaction resource to the application server. As shown inFIG. 9, the method includes the following steps.

S801. The application server sends a third transaction resource creationrequest for a second transaction to the first managed object device,where the third transaction resource creation request includes theidentifier of the first to-be-operated resource, a third execution time,and a third to-be-executed operation.

S802. The application server sends a fourth transaction resourcecreation request for the second transaction to the second managed objectdevice, where the fourth transaction resource creation request includesthe identifier of the first to-be-operated resource, a fourth executiontime, and a fourth to-be-executed operation, and the third executiontime and the fourth execution time are the same.

Specifically, the application server sends the third transactionresource creation request for the second transaction to the firstmanaged object device and the fourth transaction resource creationrequest for the second transaction to the second managed object devicerespectively, that is, both a third transaction resource and a fourthtransaction resource belong to the second transaction of the applicationserver. The third transaction resource creation request includes theidentifier of the first to-be-operated resource, the third executiontime, and the third to-be-executed operation. The fourth transactionresource creation request includes the identifier of the secondto-be-operated resource, the fourth execution time, and the fourthto-be-executed operation. The third execution time and the fourthexecution time are the same. Optionally, the third to-be-executedoperation and the fourth to-be-executed operation may be the same or maybe different. In addition, the third to-be-executed operation or thefourth to-be-executed operation may be reflected in a primitive form, ormay be reflected in another manner.

S803. The application server receives, within a preset time, a responsethat is sent by the first managed object device and that is indicativeof unsuccessful creation of a third transaction resource of the secondtransaction, and receives, within the preset time, a response that issent by the second managed object device and that is indicative ofsuccessful creation of a fourth transaction resource of the secondtransaction, where the response indicative of successful creation of thefourth transaction resource carries an identifier of the fourthtransaction resource.

Specifically, the first managed object device determines, according toinformation such as the third execution time and the thirdto-be-executed operation carried in the third transaction resourcecreation request, whether the third transaction resource can be createdsuccessfully. For a specific determining process, refer to thedetermining process in (1) to (4) in the foregoing embodiment shown inFIG. 7, and details are not described again herein.

If the first managed object device fails to check any one of theforegoing four items, it indicates that the third transaction resourcecreation request does not meet the transaction resource creationcondition. The first managed object device determines that the thirdtransaction resource fails to be created, and sends the responseindicative of unsuccessful creation of the third transaction resource ofthe second transaction to the application server. If the second managedobject device checks all the foregoing four items successfully, itindicates that the fourth transaction resource creation request meetsthe transaction resource creation condition. The second managed objectdevice can successfully create the fourth transaction resource accordingto the fourth transaction resource creation request, and send theresponse indicative of successful creation of the fourth transactionresource of the second transaction to the application server, so as tonotify the application server that the fourth transaction resource iscreated successfully. The response indicative of successful creation ofthe fourth transaction resource may carry the identifier of the fourthtransaction resource, and may further carry a state of the createdfourth transaction resource, where the state is the reserved state orthe semi-reserved state.

Optionally, when the first managed object device determines that nofirst transaction resource queue corresponding to the firstto-be-operated resource exists on the first managed object device, ifthe first managed object device determines, according to informationincluded in the third to-be-executed operation, that the thirdtransaction resource creation request does not meet the content of (1)in the foregoing transaction resource creation condition, the firstmanaged object device determines, according to the third transactionresource creation request, that the third transaction resource fails tobe created, and sends a first failure response to the applicationserver, so as to notify the application server that the thirdtransaction resource cannot be created successfully.

Optionally, when the first managed object device determines that nofirst transaction resource queue corresponding to the firstto-be-operated resource exists on the first managed object device, ifthe first managed object device determines, according to informationincluded in the third to-be-executed operation, that the thirdtransaction resource creation request does not meet the content of anyone of (2) to (4) in the foregoing transaction resource creationcondition, the first managed object device determines, according to thethird transaction resource creation request, that the third transactionresource fails to be created, and sends a second failure response thatcarries the updated third execution time to the application server, soas to notify the application server that the current third executiontime is not appropriate, but the first managed object device can createthe third transaction resource successfully by using the updated thirdexecution time carried in the second failure response.

Optionally, if the first managed object device determines, according tothe third execution time, that a first transaction resource queuecorresponding to the first to-be-operated resource exists on the firstmanaged object device, the first managed object device determines,according to the third execution time in the third transaction resourcecreation request and a state of the first to-be-operated resource, thatthe third transaction resource fails to be created. Specifically thefollowing two cases are included.

First case: The first managed object device determines, according to thethird execution time and the state of the first to-be-operated resource,that the preset resource creation condition is not met when the thirdexecution time is updated to any time later than an execution time ofeach transaction resource in the first transaction resource queue. Inthis case, the first managed object device sends the first failureresponse to the application server.

Second case: The first managed object device determines, according tothe third execution time and the state of the first to-be-operatedresource, that the preset resource creation condition is met when thethird execution time is updated to a time later than an execution timeof any transaction resource in the first transaction resource queue. Thefirst managed object device sends the second failure response thatcarries the updated third execution time to the application server. Fora specific determining process of the first managed object device, referto the technical solution in the first possible implementation manner orthe second possible implementation manner of the embodiment shown inFIG. 3. Details are not described again herein.

Therefore, the application server determines that the response that issent by the first managed object device and that is indicative ofunsuccessful creation of the third transaction resource of the secondtransaction and the response that is sent by the second managed objectdevice and that is indicative of successful creation of the fourthtransaction resource of the second transaction are received within thepreset time.

S804. The application server sends, based on the response indicative ofunsuccessful creation of the third transaction resource of the secondtransaction and the response indicative of successful creation of thefourth transaction resource of the second transaction, a processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource, where theprocessing request for the fourth transaction resource of the secondtransaction carries the identifier of the fourth transaction resource.

Specifically, after the application server receives, within the presettime, the response that is sent by the first managed object device andthat is indicative of unsuccessful creation of the third transactionresource (the response indicative of creation failure of the thirdtransaction resource is the first failure response or the second failureresponse) and the response that is sent by the second managed objectdevice and that is indicative of creation success of the fourthtransaction resource, the application server learns that the firstmanaged object device fails to create the third transaction resource andlearns that the second managed object device creates the fourthtransaction resource successfully. Therefore, the application serversends, according to the response indicative of unsuccessful creation ofthe third transaction resource, the processing request for the fourthtransaction resource of the second transaction to the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource. Specifically, the following twomanners are available:

First manner: If the application server determines that the responseindicative of unsuccessful creation of the third transaction resource isthe first failure response that does not carry the updated thirdexecution time, the application server sends a deletion request carryingthe identifier of the fourth transaction resource to the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource. Specifically, for the operationexecuted after the second managed object device receives the deletionrequest, refer to the process of deleting the fourth transactionresource by the second managed object device according to the identifierof the fourth transaction resource in the fifth possible implementationmanner of the embodiment shown in FIG. 3. Details are not describedagain herein.

Second manner: If the application server determines that the responseindicative of unsuccessful creation of the third transaction resource isthe second failure response carrying the updated third execution time,the application server sends an update request carrying the updatedthird execution time and the identifier of the fourth transactionresource to the second managed object device that sends the responseindicative of successful creation of the fourth transaction resource,where the updated third execution time is a time of successfullycreating the third transaction resource by the first managed objectdevice.

Specifically, for the operation executed after the second managed objectdevice receives the update request, refer to the process of updating thefourth transaction resource by the second managed object deviceaccording to the identifier of the fourth transaction resource and theupdated third execution time in the fourth possible implementationmanner of the embodiment shown in FIG. 3. Details are not describedagain herein.

It should be noted that, when sending the update request to the secondmanaged object device, the application server further sends a new thirdtransaction resource creation request carrying the updated thirdexecution time to the first managed object device, so that the firstmanaged object device successfully creates a new third transactionresource according to the updated third execution time. Assuming thatthe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource can alsosuccessfully update the previously created fourth transaction resourceaccording to the updated third execution time, the application serverdoes not send the processing request for the fourth transaction resourceof the second transaction to the second managed object device, that is,before the updated third execution time arrives, the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource fails to receive the processingrequest sent by the application server for the fourth transactionresource of the second transaction. Therefore, when the updated thirdexecution time arrives, the first managed object device and the secondmanaged object device can simultaneously execute the to-be-executedoperations in the transaction resources created by the devices.

In the method for executing distributed transaction resources accordingto this embodiment of the present invention, an application server sendsa third transaction resource creation request to a first managed objectdevice, and a third execution time carried in the third transactionresource creation request is the same as a fourth execution time carriedin a fourth transaction resource creation request sent by theapplication server to a second managed object device, and after theapplication server determines that a response that is sent by the firstmanaged object device and that is indicative of unsuccessful creation ofa third transaction resource and a response that is sent by the secondmanaged object device and that is indicative of successful creation of afourth transaction resource are received within a preset time, theapplication server sends a processing request for the fourth transactionresource of a second transaction to the second managed object device. Inthe method provided by this embodiment of the present invention, thesecond managed object device can ensure, according to the processingrequest sent by the application server (when the processing request isan update request), that a time of executing the updated fourthtransaction resource by the second managed object device is the same asa time at which the first managed object device executes a new thirdtransaction resource created by the first managed object device, thatis, it is ensured that the first managed object device and the secondmanaged object device can simultaneously execute operations to beexecuted by the devices. Therefore, simultaneous execution oftransaction resources is ensured.

A person of ordinary skill in the art may understand that all or somesteps of the method embodiments may be implemented by a programinstructing relevant hardware. The program may be stored in acomputer-readable storage medium. When the program runs, the steps ofthe method embodiments are performed. The storage medium includes anymedium that can store program code, such as a ROM, a RAM, a magneticdisk, or an optical disc.

FIG. 10 is a schematic structural diagram of an embodiment of anapplication server according to the present invention. As shown in FIG.10, the application server is applied to an M2M system. The M2M systemincludes at least two managed object devices and the application server.A first managed object device is any one of the at least two managedobject devices, and the second managed object is any managed objectdevice in the at least two managed object devices except the firstmanaged object device. The application server includes a sending module10 and a receiving module 11.

Specifically, the sending module 10 is configured to send a firsttransaction resource creation request for a first transaction to thefirst managed object device, where the first transaction resourcecreation request includes an identifier of a first to-be-operatedresource, a first execution time, and a first to-be-executed operation;and further configured to send a second transaction resource creationrequest for the first transaction to the second managed object device,where the second transaction resource creation request includes theidentifier of the first to-be-operated resource, a second executiontime, and a second to-be-executed operation, and the first executiontime and the second execution time are the same.

The receiving module 11 is configured to receive, within a preset time,a response that is sent by the second managed object device and that isindicative of successful creation of a second transaction resource ofthe first transaction, and receive a response that is sent by the firstmanaged object device and that is indicative of successful creation of afirst transaction resource of the first transaction.

For the application server provided by this embodiment of the presentinvention, refer to the execution process of the foregoing methodembodiment of the application server. An implementation principle and atechnical effect thereof are similar to those of the method embodiment,and details are not described again herein.

Further, the sending module 10 is further configured to send a thirdtransaction resource creation request for a second transaction to thefirst managed object device, where the third transaction resourcecreation request includes the identifier of the first to-be-operatedresource, a third execution time, and a third to-be-executed operation;and further configured to send a fourth transaction resource creationrequest for the second transaction to the second managed object device,where the fourth transaction resource creation request includes theidentifier of the second to-be-operated resource, a fourth executiontime, and a fourth to-be-executed operation, and the third executiontime and the fourth execution time are the same.

The receiving module 11 is further configured to receive, within apreset time, a response that is sent by the first managed object deviceand that is indicative of unsuccessful creation of a third transactionresource of the second transaction, and receive, within the preset time,a response that is sent by the second managed object device and that isindicative of successful creation of a fourth transaction resource ofthe second transaction, where the response indicative of successfulcreation of the fourth transaction resource carries an identifier of thefourth transaction resource. In this case, the sending module 10 isfurther configured to send, based on the response indicative ofunsuccessful creation of the third transaction resource of the secondtransaction and the response indicative of successful creation of thefourth transaction resource of the second transaction, a processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource, where theprocessing request for the fourth transaction resource of the secondtransaction carries the identifier of the fourth transaction resource.

Further, the sending module 10 is specifically configured to determinethat the response indicative of unsuccessful creation of the thirdtransaction resource of the second transaction is a first failureresponse that does not carry an updated third execution time, and send adeletion request carrying the identifier of the fourth transactionresource to the second managed object device that sends the responseindicative of successful creation of the fourth transaction resource; ordetermine that the response indicative of unsuccessful creation of thethird transaction resource of the second transaction is a second failureresponse carrying the updated third execution time, and send an updaterequest carrying the updated third execution time and the identifier ofthe fourth transaction resource to the second managed object device thatsends the response indicative of successful creation of the fourthtransaction resource; and further configured to send a third transactionresource creation request carrying the updated third execution time tothe first managed device.

For the application server provided by this embodiment of the presentinvention, refer to the execution process of the foregoing methodembodiment of the application server. An implementation principle and atechnical effect thereof are similar to those of the method embodiment,and details are not described again herein.

FIG. 11 is a schematic structural diagram of Embodiment 1 of a managedobject device according to the present invention. The managed objectdevice is applied to a machine to machine communications M2M system. TheM2M system includes at least two managed object devices and anapplication server. The managed object device is any one of the at leasttwo managed object devices, and a second managed object device is anymanaged object device in the at least two managed object devices exceptthe managed object device. As shown in FIG. 11, the managed objectdevice includes a receiving module 20, a creation module 21, adetermining module 22, and a processing module 23.

The receiving module 20 is configured to receive a first transactionresource creation request sent by the application server for a firsttransaction, where the first transaction resource creation requestincludes an identifier of a first to-be-operated resource, a firstexecution time, and a first to-be-executed operation, the firstexecution time is the same as a second execution time in a secondtransaction resource creation request for the first transaction, and thesecond transaction resource creation request is received by the secondmanaged object device other than the managed object device in the M2Msystem. The creation module 21 is configured to successfully create afirst transaction resource according to the first transaction resourcecreation request, where the first transaction resource includes thefirst execution time and the first to-be-executed operation. Thedetermining module 22 is configured to determine, when the firstexecution time arrives, that a processing request sent by theapplication server for the first transaction resource of the firsttransaction is not received, where the processing request for the firsttransaction resource of the first transaction is sent after theapplication server receives a response that is sent by the secondmanaged object device and that is indicative of unsuccessful creation ofa second transaction resource of the first transaction. The processingmodule 23 is configured to execute the first to-be-executed operation.

For the managed object device provided by this embodiment of the presentinvention, refer to the execution process of the foregoing methodembodiment. An implementation principle and a technical effect thereofare similar to those of the method embodiment, and details are notdescribed again herein.

FIG. 12 is a schematic structural diagram of Embodiment 2 of a managedobject device according to the present invention. This embodimentrelates to a specific process of creating a third transaction resourceby the managed object device. Based on the foregoing embodiment shown inFIG. 11, the managed object device further includes a sending module 24.

The receiving module 20 is further configured to receive a thirdtransaction resource creation request sent by the application server fora second transaction, where the third transaction resource creationrequest includes the identifier of the first to-be-operated resource, athird execution time, and a third to-be-executed operation, and thethird execution time is the same as a fourth execution time in a fourthtransaction resource creation request received by the second managedobject device for the second transaction. The creation module 21 isfurther configured to determine that a third transaction resource failsto be created according to the third transaction resource creationrequest. The sending module 24 is configured to send a responseindicative of unsuccessful creation of the third transaction resource ofthe second transaction to the application server.

Further, the creation module 21 is specifically configured to determinethat a first transaction resource queue exists on the managed objectdevice, determine, according to the third execution time and a state ofthe first to-be-operated resource of the managed object device, that thethird transaction resource does not meet a preset resource creationcondition, and determine, according to the preset resource creationcondition, to update the third execution time to a time later than anexecution time of a transaction resource in the first transactionresource queue, where the first transaction resource queue includes atleast one transaction resource. The sending module 24 is specificallyconfigured to send a second failure response carrying the updated thirdexecution time to the application server.

For the managed object device provided by this embodiment of the presentinvention, refer to the execution process of the foregoing methodembodiment. An implementation principle and a technical effect thereofare similar to those of the method embodiment, and details are notdescribed again herein.

Still referring to FIG. 12, this embodiment relates to a specificprocess in which the managed object device successfully creates a thirdtransaction resource, the second managed object device successfullycreates a fourth transaction resource, and the managed object deviceprocesses the created third transaction resource according to aprocessing request sent by the application server for the thirdtransaction resource of a second transaction. Specifically:

The receiving module 20 is further configured to receive a thirdtransaction resource creation request sent by the application server fora second transaction, where the third transaction resource creationrequest includes the identifier of the first to-be-operated resource, athird execution time, and a third to-be-executed operation, and thethird execution time is the same as a fourth execution time in a fourthtransaction resource creation request received by the second managedobject device for the second transaction. The creation module 21 isfurther configured to successfully create the third transaction resourceaccording to the third transaction resource creation request. Thesending module 24 is further configured to send a response indicative ofsuccessful creation of the third transaction resource of the secondtransaction to the application server, where the response indicative ofsuccessful creation of the third transaction resource carries anidentifier of the third transaction resource. The determining module 22is further configured to determine, before the third execution timearrives, that a processing request sent by the application server forthe third transaction resource of the second transaction is received,where the processing request for the third transaction resource of thesecond transaction carries the identifier of the third transactionresource. The processing module 23 is further configured to process thecreated third transaction resource according to the identifier of thethird transaction resource.

Further, the creation module 21 is specifically configured to determinethat a first transaction resource queue exists on the managed objectdevice, determine, according to the third execution time and a state ofthe first to-be-operated resource of the managed object device, that thethird transaction resource meets a preset resource creation condition,and create the third transaction resource, where the first transactionresource queue includes at least one transaction resource.

Optionally, the processing request for the third transaction resource ofthe second transaction is an update request that carries the identifierof the third transaction resource and an updated fourth execution time,and the processing module 23 is specifically configured to successfullyupdate the third transaction resource according to the updated fourthexecution time, and after the update succeeds, return an update successresponse message to the application server; or fail to update the thirdtransaction resource according to the updated fourth execution time, andreturn an update failure response message to the application server.Further, the processing module 23 is specifically configured to deletethe third transaction resource on the managed object device according tothe identifier of the third transaction resource, use the updated fourthexecution time as an execution time of a new third transaction resource,determine, according to the execution time of the new third transactionresource and the state of the first to-be-operated resource of themanaged object device, that the new third transaction resource meets thepreset resource creation condition, and create the new third transactionresource according to the updated fourth execution time.

It should be noted that, for the process of updating the thirdtransaction resource by the managed object device, refer to the processof updating the fourth transaction resource by the second managed objectdevice in the method embodiment, and details are not described againherein.

Optionally, the processing request for the third transaction resource ofthe second transaction is a deletion request that carries the identifierof the third transaction resource, and the processing module 23 isspecifically configured to delete the third transaction resource on themanaged object device according to the identifier of the thirdtransaction resource.

Optionally, one transaction resource in the first transaction resourcequeue is in a reserved state, and the processing module 23 is furtherconfigured to: determine, according to the state of the firstto-be-operated resource after a transaction resource at a first positionin the first transaction resource queue is executed, whether atransaction resource at the second position can be executedsuccessfully; and if the transaction resource at the second position isexecuted successfully, send a first deletion response to the applicationserver, and after the transaction resource at the first position isexecuted, update a state of the transaction resource at the secondposition to the reserved state; or if the transaction resource at thesecond position fails to be executed, delete the transaction resource atthe second position; where the first position is a position previous tothe third transaction resource in the first transaction resource queue,and the second position is a position next to the third transactionresource in the first transaction resource queue.

Optionally, at least two transaction resources in the first transactionresource queue are in a reserved state, and the processing module 23 isfurther configured to: determine whether a transaction resource in asemi-reserved state in the first transaction resource queue meets apreset deletion condition; and if yes, delete the transaction resourcein the semi-reserved state, and send a second deletion response to theapplication server; or if not, determine, according to the state of thefirst to-be-operated resource after any transaction resource previous tothe transaction resource in the semi-reserved state is executed, thatthe transaction resource in the semi-reserved state can be executedsuccessfully, and update the transaction resource in the semi-reservedstate to the reserved state.

It should be noted that, for the process of deleting the thirdtransaction resource by the managed object device, refer to the processof deleting the fourth transaction resource by the second managed objectdevice in the method embodiment, and details are not described againherein.

For the managed object device provided by this embodiment of the presentinvention, refer to the execution process of the foregoing methodembodiment. An implementation principle and a technical effect thereofare similar to those of the method embodiment, and details are notdescribed again herein.

FIG. 13 is a schematic structural diagram of an embodiment of a systemfor executing distributed transaction resources according to the presentinvention. The system is applied to an M2M system. The M2M systemincludes at least two managed object devices and an application server.A first managed object device 31 is any one of the at least two managedobject devices, and a second managed object device 32 is any managedobject device in the at least two managed object devices except thefirst managed object device. As shown in FIG. 13, the system forexecuting distributed transaction resources includes the first managedobject device 31 and the second managed object device 32. Specifically:

The first managed object device 31 is configured to receive a firsttransaction resource creation request sent by the application server fora first transaction, successfully create a first transaction resource ofthe first transaction according to the first transaction resourcecreation request, and send a response indicative of successful creationof the first transaction resource of the first transaction to theapplication server, where the first transaction resource creationrequest includes an identifier of a first to-be-operated resource, afirst execution time, and a first to-be-executed operation. The secondmanaged object device 32 is configured to receive a second transactionresource creation request sent by the application server for the firsttransaction, successfully create a second transaction resource of thefirst transaction according to the second transaction resource creationrequest, and send a response indicative of successful creation of thesecond transaction resource of the first transaction to the applicationserver, where the second transaction resource creation request includesan identifier of a second to-be-operated resource, a second executiontime, and a second to-be-executed operation, the first execution timeand the second execution time are the same, the first transactionresource includes the first execution time and the first to-be-executedoperation, and the second transaction resource includes the secondexecution time and the second to-be-executed operation. When the firstexecution time arrives, the first managed object device 31 and thesecond managed device 32 are configured to respectively execute theoperations to be executed by the devices.

For the system for executing distributed transaction resources accordingto this embodiment of the present invention, refer to the executionprocess of the foregoing method embodiment. An implementation principleand a technical effect thereof are similar to those of the methodembodiment, and details are not described again herein.

Further, the first managed object device 31 is further configured toreceive a third transaction resource creation request sent by theapplication server for a second transaction, determine that a thirdtransaction resource of the second transaction fails to be createdaccording to the third transaction resource creation request, and send aresponse indicative of unsuccessful creation of the third transactionresource of the second transaction to the application server, where thethird transaction resource creation request includes the identifier ofthe first to-be-operated resource, a third execution time, and a thirdto-be-executed operation. The second managed object device 32 is furtherconfigured to receive a fourth transaction resource creation requestsent by the application server for the second transaction, successfullycreate a fourth transaction resource of the second transaction accordingto the fourth transaction resource creation request, and send a responseindicative of successful creation of the fourth transaction resource ofthe second transaction to the application server, where the fourthtransaction resource creation request includes the identifier of thesecond to-be-operated resource, a fourth execution time, and a fourthto-be-executed operation, the third execution time and the fourthexecution time are the same, and the response indicative of successfulcreation of the fourth transaction resource carries an identifier of thefourth transaction resource. The second managed object device 32 thatsends the response indicative of successful creation of the fourthtransaction resource to the application server is further configured toreceive a processing request sent by the application server for thefourth transaction resource of the second transaction, and process thecreated fourth transaction resource according to the identifier of thefourth transaction resource, where the processing request for the fourthtransaction resource of the second transaction carries the identifier ofthe fourth transaction resource.

Still further, the first managed object device 31 is specificallyconfigured to determine that a first transaction resource queue existson the first managed object device 31, determine, according to the thirdexecution time and a state of the first to-be-operated resource of thefirst managed object device 31, that the third transaction resource doesnot meet a preset resource creation condition, determine, according tothe preset resource creation condition, to update the third executiontime to a time later than an execution time of a transaction resource inthe first transaction resource queue, and send a second failure responsecarrying the updated third execution time to the application server,where the first transaction resource queue includes at least onetransaction resource.

Still further, the second managed object device 32 is specificallyconfigured to determine that a second transaction resource queue existson the second managed object device 32, determine, according to thefourth execution time and a state of the second to-be-operated resourceof the second managed object device 32, that the fourth transactionresource meets the preset resource creation condition, and create thefourth transaction resource, where the second transaction resource queueincludes at least one transaction resource.

For the system for executing distributed transaction resources accordingto this embodiment of the present invention, refer to the executionprocess of the foregoing method embodiment. An implementation principleand a technical effect thereof are similar to those of the methodembodiment, and details are not described again herein.

Optionally, the processing request for the fourth transaction resourceof the second transaction is an update request that carries theidentifier of the fourth transaction resource and the updated thirdexecution time; and the second managed object device 32 is furtherconfigured to successfully update the fourth transaction resourceaccording to the updated third execution time, and after the updatesucceeds, return an update success response message to the applicationserver; or fail to update the fourth transaction resource according tothe updated third execution time, and return an update failure responsemessage to the application server.

Further, the second managed object device 32 is further configured todelete the fourth transaction resource on the second managed objectdevice 32 according to the identifier of the fourth transactionresource, use the updated third execution time as an execution time of anew fourth transaction resource, determine, according to the executiontime of the new fourth transaction resource and the state of the secondto-be-operated resource of the second managed object device 32, that thenew fourth transaction resource meets the preset resource creationcondition, and create the new fourth transaction resource according tothe updated third execution time.

For the system for executing distributed transaction resources accordingto this embodiment of the present invention, refer to the executionprocess of the foregoing method embodiment. An implementation principleand a technical effect thereof are similar to those of the methodembodiment, and details are not described again herein.

Optionally, the processing request for the fourth transaction resourceof the second transaction is a deletion request that carries theidentifier of the fourth transaction resource, and the second managedobject device 32 is further configured to delete the fourth transactionresource on the second managed object device according to the identifierof the fourth transaction resource.

Optionally, one transaction resource in the second transaction resourcequeue is in a reserved state, and the second managed object device 32 isfurther configured to determine, according to the state of the secondto-be-operated resource after a transaction resource at a first positionin the second transaction resource queue is executed, whether atransaction resource at the second position can be executedsuccessfully, where the first position is a position previous to thefourth transaction resource in the second transaction resource queue,and the second position is a position next to the fourth transactionresource in the second transaction resource queue; and if thetransaction resource at the second position is executed successfully,the second managed object device 32 is further configured to send afirst deletion response to the application server, and after thetransaction resource at the first position is executed, update a stateof the transaction resource at the second position to the reservedstate; or if the transaction resource at the second position fails to beexecuted, the second managed object device 32 is further configured todelete the transaction resource at the second position.

Optionally, at least two transaction resources in the second transactionresource queue are in a reserved state, and the second managed objectdevice 32 is further configured to determine whether a transactionresource in a semi-reserved state in the second transaction resourcequeue meets a preset deletion condition; and if the transaction resourcein the semi-reserved state in the second transaction resource queuemeets the preset deletion condition, the second managed object device 32is further configured to delete the transaction resource in thesemi-reserved state, and send a second deletion response to theapplication server; or if the transaction resource in the semi-reservedstate in the second transaction resource queue does not meet the presetdeletion condition, the second managed object device 32 is furtherconfigured to determine, according to the state of the secondto-be-operated resource after any transaction resource previous to thetransaction resource in the semi-reserved state is executed, that thetransaction resource in the semi-reserved state can be executedsuccessfully, and update the transaction resource in the semi-reservedstate to the reserved state.

For the system for executing distributed transaction resources accordingto this embodiment of the present invention, refer to the executionprocess of the foregoing method embodiment. An implementation principleand a technical effect thereof are similar to those of the methodembodiment, and details are not described again herein.

Finally, it should be noted that the foregoing embodiments are merelyintended for describing the technical solutions of the presentinvention, but not for limiting the present invention. Although thepresent invention is described in detail with reference to the foregoingembodiments, persons of ordinary skill in the art should understand thatthey may still make modifications to the technical solutions describedin the foregoing embodiments or make equivalent replacements to some orall technical features thereof, without departing from the scope of thetechnical solutions of the embodiments of the present invention.

What is claimed is:
 1. A method for executing distributed transactionresources for a machine to machine communications (M2M) system, themethod comprising: receiving, by a first managed object device of theM2M system, a first transaction resource creation request sent by anapplication server of the M2M system for a first transaction, whereinthe first transaction resource creation request comprises an identifierof a first to-be-operated resource, a first execution time, and a firstto-be-executed operation; receiving, by a second managed object deviceof the M2M system different from the first managed object device, asecond transaction resource creation request sent by the applicationserver for the first transaction, wherein the second transactionresource creation request comprises an identifier of a secondto-be-operated resource, a second execution time, and a secondto-be-executed operation; and sending, by the first managed objectdevice, a response indicative of successful creation of a firsttransaction resource of the first transaction to the application server,and sending, by the second managed object device, a response indicativeof successful creation of a second transaction resource of the firsttransaction to the application server, wherein the first transactionresource comprises the first execution time and the first to-be-executedoperation, and the second transaction resource comprises the secondexecution time and the second to-be-executed operation.
 2. The methodaccording to claim 1, wherein the method further comprises: receiving,by the first managed object device, a third transaction resourcecreation request sent by the application server for a secondtransaction, wherein the third transaction resource creation requestcomprises the identifier of the first to-be-operated resource, a thirdexecution time, and a third to-be-executed operation; receiving, by thesecond managed object device, a fourth transaction resource creationrequest sent by the application server for the second transaction,wherein the fourth transaction resource creation request comprises theidentifier of the second to-be-operated resource, a fourth executiontime, and a fourth to-be-executed operation; sending, by the firstmanaged object device, a response indicative of unsuccessful creation ofthe third transaction resource of the second transaction to theapplication server; and sending, by the second managed device, aresponse indicative of successful creation of a fourth transactionresource of the second transaction to the application server, whereinthe response indicative of successful creation of the fourth transactionresource carries an identifier of the fourth transaction resource;receiving, by the second managed object device, a processing requestsent by the application server for the fourth transaction resource ofthe second transaction, wherein the processing request for the fourthtransaction resource of the second transaction carries the identifier ofthe fourth transaction resource; and processing, by the second managedobject device, the created fourth transaction resource according to theidentifier of the fourth transaction resource.
 3. The method accordingto claim 2, wherein the method further comprises: determining, by thefirst managed object device, that a first transaction resource queueexists on the first managed object device, wherein the first transactionresource queue comprises at least one transaction resource; determining,by the first managed object device according to the third execution timeand a state of the first to-be-operated resource of the first managedobject device, that the third transaction resource does not meet apreset resource creation condition; and determining, by the firstmanaged object device according to the preset resource creationcondition, to update the third execution time to a time later than anexecution time of a transaction resource in the first transactionresource queue; and sending, by the first managed object device, asecond failure response carrying the updated third execution time to theapplication server.
 4. The method according to claim 2, wherein beforesending, by the second managed device, a response indicative ofsuccessful creation of a fourth transaction resource of the secondtransaction to the application server, the method further comprises:determining, by the second managed object device, that a secondtransaction resource queue exists on the second managed object device,wherein the second transaction resource queue comprises at least onetransaction resource; and determining, by the second managed objectdevice according to the fourth execution time and a state of the secondto-be-operated resource of the second managed object device, that thefourth transaction resource meets the preset resource creationcondition, and creating the fourth transaction resource.
 5. The methodaccording to claim 3, wherein the processing request for the fourthtransaction resource of the second transaction is an update request thatcarries the identifier of the fourth transaction resource and theupdated third execution time; and wherein the processing the createdfourth transaction resource, by the second managed object devicecomprises: successfully updating, by the second managed object device,the fourth transaction resource according to the updated third executiontime, and returning an update success response message to theapplication server; or failing to update the fourth transaction resourceaccording to the updated third execution time, and returning an updatefailure response message to the application server.
 6. The methodaccording to claim 5, wherein successfully updating the fourthtransaction resource comprises: deleting, by the second managed objectdevice, the fourth transaction resource on the second managed objectdevice according to the identifier of the fourth transaction resource;using, by the second managed object device, the updated third executiontime as an execution time of a new fourth transaction resource;determining, by the second managed object device according to theexecution time of the new fourth transaction resource and the state ofthe second to-be-operated resource of the second managed object device,that the new fourth transaction resource meets the preset resourcecreation condition; and creating, by the second managed object device,the new fourth transaction resource according to the updated thirdexecution time.
 7. The method according to claim 2, wherein theprocessing request for the fourth transaction resource of the secondtransaction is a deletion request that carries the identifier of thefourth transaction resource; and wherein the processing the createdfourth transaction resource comprises: deleting, by the second managedobject device, the fourth transaction resource on the second managedobject device according to the identifier of the fourth transactionresource.
 8. The method according to claim 4, wherein one transactionresource in the second transaction resource queue is in a reservedstate, and after the deleting the fourth transaction resource on thesecond managed object device, the method further comprises: determining,by the second managed object device, according to the state of thesecond to-be-operated resource after a transaction resource at a firstposition in the second transaction resource queue is executed, whether atransaction resource at a second position can be executed successfully,wherein the first position is a position previous to the fourthtransaction resource in the second transaction resource queue, and thesecond position is a position next to the fourth transaction resource inthe second transaction resource queue; and in response to determiningthat the transaction resource at the second position is executedsuccessfully, sending, by the second managed object device, a firstdeletion response to the application server, and after the transactionresource at the first position is executed, updating a state of thetransaction resource at the second position to the reserved state; or inresponse to determining that the transaction resource at the secondposition fails to be executed, deleting, by the second managed objectdevice, the transaction resource at the second position.
 9. The methodaccording to claim 7, wherein at least two transaction resources in thesecond transaction resource queue are in a reserved state, and after thedeleting the fourth transaction resource on the second managed objectdevice, the method further comprises: determining, by the second managedobject device, whether a transaction resource in a semi-reserved statein the second transaction resource queue meets a preset deletioncondition; and in response to determining that the transaction resourcein the semi-reserved state in the second transaction resource queuemeets the preset deletion condition, deleting, by the second managedobject device, the transaction resource in the semi-reserved state, andsending a second deletion response to the application server; or inresponse to determining that the transaction resource in thesemi-reserved state in the second transaction resource queue does notmeet the preset deletion condition, determining, by the second managedobject device, according to the state of the second to-be-operatedresource after any transaction resource previous to the transactionresource in the semi-reserved state is executed, that the transactionresource in the semi-reserved state can be executed successfully, andupdating, by the second managed object device, the transaction resourcein the semi-reserved state to the reserved state.
 10. The methodaccording to claim 1, wherein the method further comprises: when thefirst execution time arrives, executing, by the first managed objectdevice, the first to-be-executed operation; and when the secondexecution time arrives, executing, by the second managed object device,the second to-be-executed operation.
 11. A method for executingdistributed transaction resources for a machine to machinecommunications (M2M) system, the method comprising: sending, by anapplication server of the M2M system, a first transaction resourcecreation request for a first transaction to a first managed objectdevice of the M2M system, wherein the first transaction resourcecreation request comprises an identifier of a first to-be-operatedresource, a first execution time, and a first to-be-executed operation;sending, by the application server, a second transaction resourcecreation request for the first transaction to a second managed objectdevice of the M2M system, wherein the second transaction resourcecreation request comprises an identifier of a second to-be-operatedresource, a second execution time, and a second to-be-executedoperation; and receiving, by the application server, within a presettime, a response that is sent by the second managed object device andthat is indicative of successful creation of a second transactionresource of the first transaction, and receiving, within the presettime, a response that is sent by the first managed object device andthat is indicative of successful creation of a first transactionresource of the first transaction.
 12. The method according to claim 11,wherein the method further comprises: sending, by the applicationserver, a third transaction resource creation request for a secondtransaction to the first managed object device, wherein the thirdtransaction resource creation request comprises the identifier of thefirst to-be-operated resource, a third execution time, and a thirdto-be-executed operation; sending, by the application server, a fourthtransaction resource creation request for the second transaction to thesecond managed object device, wherein the fourth transaction resourcecreation request comprises the identifier of the second to-be-operatedresource, a fourth execution time, and a fourth to-be-executedoperation; receiving, by the application server, within a preset time, aresponse that is sent by the first managed object device and that isindicative of unsuccessful creation of a third transaction resource ofthe second transaction, and receiving, within the preset time, aresponse that is sent by the second managed object device and that isindicative of successful creation of a fourth transaction resource ofthe second transaction, wherein the response indicative of successfulcreation of the fourth transaction resource carries an identifier of thefourth transaction resource; and sending, by the application server,according to the response indicative of unsuccessful creation of thethird transaction resource of the second transaction and the responseindicative of successful creation of the fourth transaction resource ofthe second transaction, a processing request for the fourth transactionresource of the second transaction to the second managed object devicethat sends the response indicative of successful creation of the fourthtransaction resource, wherein the processing request for the fourthtransaction resource of the second transaction carries the identifier ofthe fourth transaction resource.
 13. The method according to claim 12,wherein sending the processing request for the fourth transactionresource comprises: determining, by the application server, that theresponse indicative of unsuccessful creation of the third transactionresource of the second transaction is a first failure response that doesnot carry an updated third execution time, and sending a deletionrequest carrying the identifier of the fourth transaction resource tothe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource; or determining,by the application server, that the response indicative of unsuccessfulcreation of the third transaction resource of the second transaction isa second failure response carrying an updated third execution time, andsending an update request carrying the updated third execution time andthe identifier of the fourth transaction resource to the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource; and wherein the method furthercomprises: sending, by the application server, a third transactionresource creation request carrying the updated third execution time tothe first managed object device.
 14. An application server for a machineto machine communications (M2M) system comprising: a processor; a memorystoring a program to be executed in the processor, the programcomprising instructions for: sending a first transaction resourcecreation request for a first transaction to a first managed objectdevice of the M2M system, wherein the first transaction resourcecreation request comprises an identifier of a first to-be-operatedresource, a first execution time, and a first to-be-executed operation;sending a second transaction resource creation request for the firsttransaction to a second managed object device of the M2M system, whereinthe second transaction resource creation request comprises theidentifier of the first to-be-operated resource, a second executiontime, and a second to-be-executed operation; receiving, within a presettime, a response that is sent by the second managed object device andthat is indicative of successful creation of a second transactionresource of the first transaction; and receiving a response that is sentby the first managed object device and that is indicative of successfulcreation of a first transaction resource of the first transaction. 15.The application server according to claim 14, wherein the instructionsfor sending comprise further instructions for: sending a thirdtransaction resource creation request for a second transaction to thefirst managed object device, wherein the third transaction resourcecreation request comprises the identifier of the first to-be-operatedresource, a third execution time, and a third to-be-executed operation;and sending a fourth transaction resource creation request for thesecond transaction to the second managed object device, wherein thefourth transaction resource creation request comprises the identifier ofthe second to-be-operated resource, a fourth execution time, and afourth to-be-executed operation; receiving, within a preset time, aresponse that is sent by the first managed object device and that isindicative of unsuccessful creation of a third transaction resource ofthe second transaction; receiving, within the preset time, a responsethat is sent by the second managed object device and that is indicativeof successful creation of a fourth transaction resource of the secondtransaction, wherein the response indicative of successful creation ofthe fourth transaction resource carries an identifier of the fourthtransaction resource; and sending, based on the response indicative ofunsuccessful creation of the third transaction resource of the secondtransaction and the response indicative of successful creation of thefourth transaction resource of the second transaction, a processingrequest for the fourth transaction resource of the second transaction tothe second managed object device that sends the response indicative ofsuccessful creation of the fourth transaction resource, wherein theprocessing request for the fourth transaction resource of the secondtransaction carries the identifier of the fourth transaction resource.16. The application server according to claim 15, wherein theinstructions for sending comprise further instructions for: determiningthat the response indicative of unsuccessful creation of the thirdtransaction resource of the second transaction is a first failureresponse that does not carry an updated third execution time, and send adeletion request carrying the identifier of the fourth transactionresource to the second managed object device that sends the responseindicative of successful creation of the fourth transaction resource; ordetermining that the response indicative of unsuccessful creation of thethird transaction resource of the second transaction is a second failureresponse carrying the updated third execution time, and sending anupdate request carrying the updated third execution time and theidentifier of the fourth transaction resource to the second managedobject device that sends the response indicative of successful creationof the fourth transaction resource; and sending a third transactionresource creation request carrying the updated third execution time tothe first managed device.
 17. A managed object device in a machine tomachine communications (M2M) system, the managed object devicecomprising: a processor; a memory storing a program to be executed inthe processor, the program comprising instructions for: receiving afirst transaction resource creation request sent by an applicationserver of the M2M system for a first transaction, wherein the firsttransaction resource creation request comprises an identifier of a firstto-be-operated resource, a first execution time, and a firstto-be-executed operation, and the second transaction resource creationrequest is received by a second managed object device of the M2M systemother than the managed object device in the M2M system; sending aresponse indicative of successful creation of a first transactionresource of the first transaction to the application server, wherein thefirst transaction resource comprises the first execution time and thefirst to-be-executed operation; determining, when the first executiontime arrives, that a processing request sent by the application serverfor the first transaction resource of the first transaction is notreceived, wherein the processing request for the first transactionresource of the first transaction is sent after the application serverreceives a response that is sent by the second managed object device andthat is indicative of unsuccessful creation of a second transactionresource of the first transaction; and executing the firstto-be-executed operation.
 18. The managed object device according toclaim 17, wherein the program comprises further instructions for:receiving a third transaction resource creation request sent by theapplication server for a second transaction, wherein the thirdtransaction resource creation request comprises the identifier of thefirst to-be-operated resource, a third execution time, and a thirdto-be-executed operation; determining that a third transaction resourcewas not created according to the third transaction resource creationrequest; and sending a response indicative of unsuccessful creation ofthe third transaction resource of the second transaction to theapplication server.
 19. The managed object device according to claim 18,wherein the instructions for successfully creating comprise furtherinstructions for: determining that a first transaction resource queueexists on the managed object device; determining, according to the thirdexecution time and a state of the first to-be-operated resource of themanaged object device, that the third transaction resource does not meeta preset resource creation condition; determining, according to thepreset resource creation condition, to update the third execution timeto a time later than an execution time of a transaction resource in thefirst transaction resource queue, wherein the first transaction resourcequeue comprises at least one transaction resource; and the instructionsfor sending further comprising instructions for sending a second failureresponse carrying the updated third execution time to the applicationserver.
 20. The managed object device according to claim 17, wherein theprogram comprises further instructions for: receiving a thirdtransaction resource creation request sent by the application server fora second transaction, wherein the third transaction resource creationrequest comprises the identifier of the first to-be-operated resource, athird execution time, and a third to-be-executed operation; successfullycreating a third transaction resource according to the third transactionresource creation request; sending a response indicative of successfulcreation of the third transaction resource of the second transaction tothe application server, wherein the response indicative of successfulcreation of the third transaction resource carries an identifier of thethird transaction resource; determining, before the third execution timearrives, that a processing request sent by the application server forthe third transaction resource of the second transaction is received,wherein the processing request for the third transaction resource of thesecond transaction carries the identifier of the third transactionresource; and processing the created third transaction resourceaccording to the identifier of the third transaction resource.